1

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?

1
  • find(specs, Button3) Commented Nov 4, 2014 at 21:02

1 Answer 1

2

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)
}
Sign up to request clarification or add additional context in comments.

1 Comment

and for remove a value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.