【发布时间】:2012-05-29 12:25:25
【问题描述】:
我对 ios 开发非常陌生,我正在尝试将一些值从 NSMutableDictionary 添加到 NSMutableArray,当我运行代码时出现此错误
2012-05-29 14:09:34.913 iShop[7464:f803] -[__NSCFArray objectForKey:]: 无法识别的选择器发送到实例 0x6e423d0 2012-05-29 14:09:34.915 iShop[7464:f803] * 由于未捕获而终止应用程序 异常'NSInvalidArgumentException',原因:'-[__NSCFArray objectForKey:]: 无法识别的选择器发送到实例 0x6e423d0' * 第一次抛出调用栈:(0x13cb022 0x155ccd6 0x13cccbd 0x1331ed0 0x1331cb2 0x2bb7 0x13cce42 0x93b9df 0x139f94f 0x1302b43 0x1302424 0x1301d84 0x1301c9b 0x12b47d8 0x12b488a 0x15626 0x28bd 0x2825) 终止称为抛出异常(lldb)
下面是我的代码:
-(void) getData:(NSData *) response {
NSError *error;
NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:response options:kNilOptions error:&error];
//NSLog(@"%@", json);
jsonArray = [[NSMutableArray alloc] init];
jsonArray = [json objectForKey:@"Name"];
NSLog(@"%@", jsonArray);
}
- (void)viewDidLoad {
[super viewDidLoad];
jsonURL = [NSURL URLWithString:@"http://localhost:8888/read_product_list.php"];
dispatch_async(BgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL:jsonURL];
[self performSelectorOnMainThread:@selector(getData:)
withObject:data waitUntilDone:YES];
});
}
【问题讨论】:
标签: objective-c ios