gpt4 book ai didi

json - 如何从 nsdictionary swift 获取数组

转载 作者:行者123 更新时间:2023-11-30 10:16:36 24 4
gpt4 key购买 nike

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

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

DISCTIONARY

最佳答案

试试这个:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com