- [__ NSDictionaryI名]:「 - [__ NSDictionaryI名]:發送到實例0x7fae38527a80 終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因無法識別選擇無法識別的選擇發送到!例如0x7fae38527a80' [在這裏輸入的形象描述] [1]- [__ NSDictionaryI名]:在目標C無法識別選擇
imageid = @"ImageID";
name = @"Name";
path = @"Path";
// And add a few recipes to it
recipes = [NSMutableArray arrayWithCapacity:10];
Recipe* recipe = [[Recipe alloc] init];
// recipe.name = @"Image 1";
// recipe,path = @"http://absolutesoft.net/test/ios/col/img/img1.png";
// recipe.image = [UIImage imageNamed:@"Image 2"];
// [recipes addObject:recipe];
NSData *jsonData = [NSData dataWithContentsOfURL:
[NSURL URLWithString:@"http://absolutesoft.net/test/ios/col/getImages.php"]];
id jsonObjects = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];
// values in foreach loop
for (NSDictionary *dataDict in jsonObjects) {
recipe.image = [dataDict objectForKey:@"ImageID"];;
recipe.name = [dataDict objectForKey:@"Name"];
recipe.Path = [dataDict objectForKey:@"Path"];
NSLog(@"recipe.image %@",recipe.image);
NSLog(@"recipe.name %@",recipe.image);
NSLog(@"recipe.Path %@",recipe.Path);
dict = [NSDictionary dictionaryWithObjectsAndKeys:
recipe.image, imageid,
recipe.name, name,
recipe.Path, path,
nil];
[recipes addObject:dict];
}
//NSLog(@"Dict = %@",dict);
NSLog(@"recipes = %@",recipes);
請添加正確的問題描述。只是發佈錯誤消息不會給你任何幫助。 – Fred 2014-10-20 13:44:14
是什麼讓你覺得'jsonObjects'是一個'NSDictionary'? – zaph 2014-10-20 13:49:59