Zheng Xie
Zheng Xie

Reputation: 415

Swift Get Value for NSDictionary

I Xcode, I can see the value for item.body(). and then iterate each of the user. but I can not get the value for users. Please see the attached image. Thanks! enter image description here

Upvotes: 1

Views: 7179

Answers (1)

tmpz
tmpz

Reputation: 368

form item.body() you are getting a dictionary of [NSObject:AnyObject]. You have to cast that to what you expect the dictionary to look like. I assume here it's [String:AnyObject] so do:

let myStringDict = item.body as? [String:AnyObject]

the you can access they value for the key "users" like:

myStringDict?["users"]

Upvotes: 6

Related Questions