I have checked this SO answer to find a solution for the deprecated find
method, but the solution is for single array. In my project I am have two arguments that are both collection types. Through refactoring I am receiving the familiar conditional binding errors.
I have tried removing the conditional binding and using index(of: )
as in the SO answer I referenced, but since I'm not working with single elements like String types naturally I get tuple errors.
If methods can't be called on tuples why was the original find
method able to call the tuple in the Swift 2 line below?
class MoneyPickerTableViewController: UITableViewController {
var money: [String: String]
var purchaseOrder: [String]
var chosenKey: String = USDPreferences.shared().object(forKey: kUSDChosenMoneyKey) as! String
// Swift 2
if let index = find(purchaseOrder, chosenKey) {
let indexPath = NSIndexPath(forRow: index, inSection: 0)
tableView.selectRowAtIndexPath(indexPath, animated: animated, scrollPosition: .Middle)
}
navigationController?.setNavigationBarHidden(false, animated: animated)
}
Swift 3
let collections = (purchaseOrder, chosenKey) as ([String], String)
let index = collections.index(of: )