【发布时间】:2014-10-20 13:39:52
【问题描述】:
-[__NSDictionaryI name]:无法识别的选择器发送到实例 0x7fae38527a80 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSDictionaryI name]:无法识别的选择器发送到实例 0x7fae38527a80” ![在此处输入图片说明][1]
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);
【问题讨论】:
-
请添加正确的问题描述。仅发布错误消息不会为您提供任何帮助。
-
是什么让你认为
jsonObjects是NSDictionary?
标签: objective-c xcode