gpt4 book ai didi

ios - 我如何从 NSDictionary 中获取属性?

转载 作者:行者123 更新时间:2023-11-28 18:44:28 26 4
gpt4 key购买 nike

我有一个网络服务,它以 JSON 格式将数据返回到我的客户端应用程序。我正在使用 TouchJson然后将此数据反序列化为 NSDictionary。伟大的。该字典包含一个键“results”,results 包含一个 NSArray 对象。

这些对象在打印到日志时看起来像这样

NSLog(@"Results Contents: %@",[resultsArray objectAtIndex:0 ]);

输出:

Results Contents: {
creationdate = "2011-06-29 22:03:24";
id = 1;
notes = "This is a test item";
title = "Test Item";
"users_id" = 1;
}

我不能确定这个对象是什么类型。如何从此对象获取属性和值?

谢谢!

最佳答案

要获取 NSDictionary 的内容,您必须为要检索的值提供键。即:

NSString *notes = [[resultsArray objectAtIndex:0] valueForKey:@"notes"];

关于ios - 我如何从 NSDictionary 中获取属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6542179/

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