【发布时间】:2012-01-09 07:28:12
【问题描述】:
我从 php 脚本中提取图片的位置,如果没有图片位置,它会在 JSON 输出中显示该位置的“null”。这在我的代码中引发了异常。这是不起作用的代码:
NSString *piclocation = picloc;
if(piclocation == nil || @"null"){
}else{
NSString *mutableUrlString = @"https://www.mypage.com/uploads";
mutableUrlString = [mutableUrlString stringByAppendingString: piclocation];
NSLog(mutableUrlString);
NSURL *url = [NSURL URLWithString: mutableUrlString];
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
imageView.image = image;
}
错误是:由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“* -[NSNull length]: unrecognized selector sent to instance 0x98d5a0” 有什么建议吗?
【问题讨论】:
标签: objective-c cocoa-touch iphone-sdk-3.0