I am trying to implement code from SO answer with a slight modification but having problems:
Here is the original code:
dispatch_async(kBgQueue, ^{
NSData *imgData = [NSData dataWithContentsOfURL:[NSURL
URLWithString:[NSString stringWithFormat:@"http://myurl.com/%@.jpg",
[[myJson objectAtIndex:indexPath.row] objectForKey:@"movieId"]]]];
Here is my code:
NSString *picname = item.pic;
NSString *picURL = [NSString stringWithFormat:@"http://www.~com/itempics/%@",item.pic];
NSURL *urlPicUrl = [NSURL URLWithString:picURL];
dispatch_async(kBgQueue, ^{
NSData *imgData = [NSData dataWithContentsOfURL:
[NSURL URLWithString:picURL]]; //THROWS ERROR
My code is throwing error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'
Would appreciate it if anyone can spot what is causing this error:
I guess item.pic
is null. And picname
is never used in your code.
Did you miss something to paste in your code?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.