我有一个带
的简单数组var specs : [String] = [Button1,Button2,Button3,Button4]
如何在我的erray中找到某个值(类型为Button3),从而取消?
答案 0 :(得分:2)
您可以使用find()
全局函数来检索索引:
var specs : [String] = ["Button1","Button2","Button3","Button4"]
let index = find(specs, "Button3")
然后,一旦验证该元素存在(find
返回一个可选项),请将其删除:
if let index = index {
specs.removeAtIndex(index)
}