我有一个数组匹配阵列字符串值3
public var options = [String]()
// VALUES = John-34 , Mike-56 , Marry-43 etc..
,我有功能
public func getIndex(id : Int){
if let index = options.contains("-\(id)".lowercased()) {
selectedIndex = index
print("\(options[index])").
}
}
我想获得选定的索引与我的功能等;
getIndex(编号:34) //必须是SHOW约翰 - 34
但不工作?任何想法? id是唯一的,只能显示1个索引。
你为什么用这些奇怪的复合参数让自己的生活变得如此艰难?这是一种面向对象的语言。使用自定义结构。 – vadian