我有以下 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.
关于json - 如何从 nsdictionary swift 获取数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29619979/