Skip to content

Commit

Permalink
Moved user info for tableview notifications to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
charliescheer committed Oct 19, 2024
1 parent d249b6f commit 90c7760
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Simplenote/NSTableView+Simplenote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ extension NSTableView {
}
}
}

extension NSTableView {
static var currentRowSelectionUserInfoKey: String {
"NSTableViewCurrentRowSelectionUserInfoKey"
}

static var previousRowSelectionUserInfoKey: String {
"NSTableViewPreviousRowSelectionUserInfoKey"
}
}
4 changes: 2 additions & 2 deletions Simplenote/NoteListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -583,15 +583,15 @@ extension NoteListViewController: SPTableViewDelegate {
}

private func shouldCheckForEmptyNote(notification: Notification) -> Bool {
guard let currentRowSelection = notification.userInfo?["NSTableViewCurrentRowSelectionUserInfoKey"] as? NSIndexSet else {
guard let currentRowSelection = notification.userInfo?[NSTableView.currentRowSelectionUserInfoKey] as? NSIndexSet else {
return false
}

return currentRowSelection.count == 1
}

private func previousSelectedIndex(from notification: Notification) -> Int? {
guard let previousSelectedIndexSet = notification.userInfo?["NSTableViewPreviousRowSelectionUserInfoKey"] as? NSIndexSet,
guard let previousSelectedIndexSet = notification.userInfo?[NSTableView.previousRowSelectionUserInfoKey] as? NSIndexSet,
previousSelectedIndexSet.count == 1 else {
return nil
}
Expand Down

0 comments on commit 90c7760

Please sign in to comment.