Search code examples
arraysswiftswift2nsarray

Swift2 check array in dictionary


I am trying to create case in one line but I can not find how can I do that

I need to write that code in one line

     if let holdings = i["holdings"] as Array where !holdings.isEmpty {

any ideas?


Solution

  • AnyObject since your didn't specify what was inside your array.

    if let holdings = i["key"] as? [AnyObject] where !holdings.isEmpty
    

    or

    if let holdings = i["key"] as? Array<AnyObject> where !holdings.isEmpty