我是很新的iOS開發,我想一些添加值從NSMutableDictionary
到NSMutableArray
,當我運行代碼,我得到這個錯誤錯誤的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];
});
}