ios - How to parse NSMutableDictionary in Swift programming? -


in apple watch interface controller "reply" object contains json response in nsdictionary. here response need "accountname" below response. how parse in swift programming.

[accounts: (     {     accountname = "abcd";     idnumber = 114000093;     email = "xyz@gmail.com";     index = 0;     nickname = "suites";     },     {     accountname = "efgh";     idnumber = 114000094;     email = "abc@gmail.com";     index = 1;     nickname = "sultan";    } )] 

i have tried below:

wkinterfacecontroller.openparentapplication(["request" : "getdata"], reply: { (reply, error) -> void in          println(reply)          self.accountnames = reply["accounts"] as? nsmutablearray          println(self.accountnames) 

this easy, can try out own, , can google also, there lots , lots of example available, need brush little bit.

btw, can try this,

let accountarray : nsarray = reply.objectforkey("accounts") as! nsarray let accountdic : nsdictionary = accountarray.objectatindex(0) as! nsdictionary let accountname : nsstring = accountdic.valueforkey("accountname") as! nsstring 

hope, helps you.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -