【发布时间】:2012-06-05 08:50:58
【问题描述】:
你好,我为 web 服务创建了一个 json 字符串,我想输出名称和描述以在 NSLog 中显示它。我怎样才能做到这一点。到目前为止,这是我的代码:
dic = [NSJSONSerialization JSONObjectWithData:result options:kNilOptions error:nil];
NSLog(@"Results %@",[NSString stringWithFormat:@"%@",[[dic objectForKey:@"d"]objectForKey:@"Name"]]);
我得到这个错误:
-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x6b50f30
当我在我的字典中创建一个 NSLog 时,我得到了这个:
{
d = "{
\n \"Name\": \"Apple\",
\n \"Beschreibung\": \"Steve Jobs ist tot\"}";
}
我来自 werbservice 的 json 字符串如下所示:
string json = @"{
""Name"": ""Apple"",
""Beschreibung"": ""Steve Jobs ist tot""}";
【问题讨论】:
-
您的网络服务返回一个 JSON 字符串。字符串的 contents 是字典的 JSON 表示。也就是说,字典已被序列化为字符串,然后该字符串已被序列化为其 JSON 表示形式。
标签: asp.net ios xcode json dictionary