我正在尝试使用json框架访问web服务。
代码:
NSDictionary *allData;
NSMutableDictionary *displayData;
NSString *string = [[NSString alloc] initWithFormat:@"http://localhost/Gangbucks.svc/GetDealList"];
NSURL *jsonURL = [NSURL URLWithString:string];
NSString *jsonData = [[NSString alloc] initWithContentsOfURL:jsonURL];
self.allData = [jsonData JSONValue];
NSLog(@"allData value is1:%@", self.allData);
self.displayData = [[NSMutableDictionary alloc] initWithDictionary:self.allData];
NSLog(@"displayData value is2:%@", self.displayData);
allData
工作正常但我在displayData
2011-12-13 14:59:23.875 IPhone[352:207] -[__NSArrayM getObjects:andKeys:]: unrecognized selector sent to instance 0x59e1c20
2011-12-13 14:59:23.878 IPhone[352:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM getObjects:andKeys:]: unrecognized selector sent to instance 0x59e1c20'
*** Call stack at first throw:
是否可以将数据从NSDictionary传递到NSMutableDictionary?
答案 0 :(得分:3)
allData显然是NSArray,而不是NSDictionary。你应该回去查看你的JSON。顶层可能有一个数组。