如何从nsdictionary swift获取数组

时间:2015-04-14 05:46:14

标签: json swift nsdictionary

我有json对象。我正在解析json并将其存储为disctionary。现在我想从disctionary获取这些数组,但是当我使用objectForKey(“comingsentointments”)时,它什么都没给我

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

DISCTIONARY

1 个答案:

答案 0 :(得分:1)

试试这个:

var dictionary = //NSDictionary from somewhere...

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

//Same goes for other such json fields.