【发布时间】:2011-06-22 16:21:09
【问题描述】:
我是 JSON 新手,刚开始了解它的功能。
我正在尝试查看是否可以从某些 JSON 方法中获取打印一些数据。我一直在第一个和被注释掉的那个之间交替。想法是看看我是否可以打印 anything:
id newConnection = [scAPI performMethod:@"GET" onResource:@"me/connections.json" withParameters:nil context:nil userInfo:nil];
// id newConnection = [scAPI performMethod:@"POST"
// onResource:@"connections"
// withParameters:[NSDictionary dictionaryWithObjectsAndKeys:
// @"facebook_profile", @"service",
// @"imc://connection", @"redirect_uri",
// @"touch", @"display", //optional, forces services to use the mobile auth page if available
// nil]
// context:nil
// userInfo:nil];
NSLog(@"newConnection %@", newConnection);
NSLog(@"Is of type: %@", [newConnection class]);
NSDictionary *dict = [newConnection objectFromJSONString];
for (id key in dict) {
NSLog(@"key: %@, value: %@", key, [dict objectForKey:key]);
}
上面的代码没有出错,我得到的日志如下:
这看起来对吗?如何正确使用这些 JSON 方法来获取值字典?
编辑 1
要清楚我正在使用 JSONKit :)
【问题讨论】:
-
要写字典来记录你可以简单地使用
NSLog(@"%@", dict);。您的字典似乎是空的(或为零),因为日志中没有显示“key .. value ..” -
@babbidi。确切地。任何想法为什么?
标签: iphone objective-c xcode json http