Reputation: 65
I have a simple array with
var specs : [String] = [Button1,Button2,Button3,Button4]
How can I find a certain value (type Button3) in my erray and therefore cancel?
Upvotes: 1
Views: 67
Reputation: 72760
You can use the find()
global function to retrieve the index:
var specs : [String] = ["Button1","Button2","Button3","Button4"]
let index = find(specs, "Button3")
and then, once verified that the element exists (find
returns an optional), remove it:
if let index = index {
specs.removeAtIndex(index)
}
Upvotes: 2