有两个数组:idArrayInt和nameArrayString。我需要通过索引从第一个数组获取一个对象,我从第二个获得。我知道这很简单,但我是IOS开发的新手,并不了解如何实现它。
var idArray = [Int]() //for example 1 2 3
var nameArray = [String]() // for example "one" "two" "three"
var ident: Int!
@IBAction func btnNext_click(_ sender: AnyObject) {
var nameString = lblUnitType.text
var index = nameArray.index(of: nameString) //Cannot invoke 'index' with an argument list of type '(of: String?)'
ident = idArray[index] //something like that by I don't sure
}