Dattatray Deokar
Dattatray Deokar

Reputation: 2103

How to get array from nsdisctionary swift

I have below json object. i am parsing json and storing this as disctionary. now i want to get these array from disctionary but when i am using objectForKey("upcomingAppointments") it given me nothing

{
  "upcomingAppointments": [],
  "upcomingFollowUps": [],
  "followUps": []
}

DISCTIONARY

Upvotes: 0

Views: 40

Answers (1)

Abdullah
Abdullah

Reputation: 7233

Try this:

var dictionary = //NSDictionary from somewhere...

if let upcomingAppointments = dictionary["upcomingAppointments"] as? NSArray {
    //Process your appointments here.
}

//Same goes for other such json fields.

Upvotes: 1

Related Questions