Browse Source

Type strict!

pull/92/head
Abhishek 4 years ago
parent
commit
b9d6782c53
  1. 17
      Clocker/Preferences/General/SearchDataSource.swift

17
Clocker/Preferences/General/SearchDataSource.swift

@ -29,7 +29,7 @@ class SearchDataSource: NSObject {
"EST": ["florida", "new york"], "EST": ["florida", "new york"],
"EDT": ["florida", "new york"]] "EDT": ["florida", "new york"]]
private var filteredArray: [Any] = [] private var filteredArray: [TimezoneData] = []
private var timezoneArray: [TimezoneMetadata] = [] private var timezoneArray: [TimezoneMetadata] = []
var timezoneFilteredArray: [TimezoneMetadata] = [] var timezoneFilteredArray: [TimezoneMetadata] = []
@ -44,7 +44,7 @@ class SearchDataSource: NSObject {
filteredArray = [] filteredArray = []
} }
func setFilteredArrayValue(_ newArray: [Any]) { func setFilteredArrayValue(_ newArray: [TimezoneData]) {
filteredArray = newArray filteredArray = newArray
} }
@ -53,12 +53,7 @@ class SearchDataSource: NSObject {
} }
func retrieveFilteredResult(_ index: Int) -> TimezoneData? { func retrieveFilteredResult(_ index: Int) -> TimezoneData? {
guard let dataObject = filteredArray[index % filteredArray.count] as? TimezoneData else { return filteredArray[index % filteredArray.count]
assertionFailure("Data was unexpectedly nil")
return nil
}
return dataObject
} }
private func setupTimezoneDatasource() { private func setupTimezoneDatasource() {
@ -204,11 +199,7 @@ extension SearchDataSource {
private func cityCell(_ tableView: NSTableView, _: RowType, _ row: Int) -> NSView? { private func cityCell(_ tableView: NSTableView, _: RowType, _ row: Int) -> NSView? {
if let cityCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "resultCell"), owner: self) as? SearchResultTableViewCell { if let cityCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "resultCell"), owner: self) as? SearchResultTableViewCell {
guard let timezoneData = filteredArray[row % filteredArray.count] as? TimezoneData else { let timezoneData = filteredArray[row % filteredArray.count]
assertionFailure()
return nil
}
cityCell.sourceName.stringValue = timezoneData.formattedAddress ?? "Error" cityCell.sourceName.stringValue = timezoneData.formattedAddress ?? "Error"
return cityCell return cityCell
} }

Loading…
Cancel
Save