如何从 nsdictionary swift 获取数组

How to get array from nsdisctionary swift

我有以下 json 个对象。我正在解析 json 并将其存储为字典。现在我想从字典中获取这些数组但是当我使用 objectForKey("upcomingAppointments") 它什么也没给我

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

试试这个:

var dictionary = //NSDictionary from somewhere...

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

//Same goes for other such json fields.