swift - Find an item index using two collection type arguments -


i have checked so answer find solution deprecated find method, solution single array. in project have 2 arguments both collection types. through refactoring receiving familiar conditional binding errors.

i have tried removing conditional binding , using index(of: ) in answer referenced, since i'm not working single elements string types naturally tuple errors.

if methods can't called on tuples why original find method able call tuple in 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) ([string], string)  let index = collections.index(of: ) 

find(_:_:) used free function took collection first argument, , desired element second.

since swift 2, functionality implemented instance method on collection, called index(of:).

what used find(purchaseorder, chosenkey) spelled purchaseorder.index(of: chosenkey)


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -