0
array = [
    “test” = test
    “test1” = test
    “test2” = test  
    “test4” = test  
]

Check if test3 is in the array

I tried to do this:

if let check= userObject[“test3”]{

}

My app crashes and I get this error: unexpectedly found nil while unwrapping an Optional value

1
  • 2
    Aren't you getting error on your array declaration? Commented Feb 5, 2016 at 10:08

1 Answer 1

1

You need to have commas separating your objects, and that's a dictionary, not an array.

var dict: [String: AnyObject] = [:]

dict = [
    "test": test,
    "test1": test,
    "test2": test,  
    "test4": test 
]
Sign up to request clarification or add additional context in comments.

Comments

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.