From b9d6782c5336a54b38bf08725436d61c71ba9447 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sat, 6 Feb 2021 18:13:22 -0600 Subject: [PATCH] Type strict! --- .../Preferences/General/SearchDataSource.swift | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/Clocker/Preferences/General/SearchDataSource.swift b/Clocker/Preferences/General/SearchDataSource.swift index ed8d6d9..28b37eb 100644 --- a/Clocker/Preferences/General/SearchDataSource.swift +++ b/Clocker/Preferences/General/SearchDataSource.swift @@ -29,7 +29,7 @@ class SearchDataSource: NSObject { "EST": ["florida", "new york"], "EDT": ["florida", "new york"]] - private var filteredArray: [Any] = [] + private var filteredArray: [TimezoneData] = [] private var timezoneArray: [TimezoneMetadata] = [] var timezoneFilteredArray: [TimezoneMetadata] = [] @@ -44,7 +44,7 @@ class SearchDataSource: NSObject { filteredArray = [] } - func setFilteredArrayValue(_ newArray: [Any]) { + func setFilteredArrayValue(_ newArray: [TimezoneData]) { filteredArray = newArray } @@ -53,12 +53,7 @@ class SearchDataSource: NSObject { } func retrieveFilteredResult(_ index: Int) -> TimezoneData? { - guard let dataObject = filteredArray[index % filteredArray.count] as? TimezoneData else { - assertionFailure("Data was unexpectedly nil") - return nil - } - - return dataObject + return filteredArray[index % filteredArray.count] } private func setupTimezoneDatasource() { @@ -204,11 +199,7 @@ extension SearchDataSource { private func cityCell(_ tableView: NSTableView, _: RowType, _ row: Int) -> NSView? { if let cityCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "resultCell"), owner: self) as? SearchResultTableViewCell { - guard let timezoneData = filteredArray[row % filteredArray.count] as? TimezoneData else { - assertionFailure() - return nil - } - + let timezoneData = filteredArray[row % filteredArray.count] cityCell.sourceName.stringValue = timezoneData.formattedAddress ?? "Error" return cityCell }