I am getting some JSON data from a service, one property is a string to represent an image url, it seems what is returned is NULL, I do the check but XCode breaks before my if statement and generate an exception. this is my code below:
- (void)configureCellForAlbum:(Album *)album {
self.albumTitle.text = album.albumTitle;
self.artisteName.text = album.artisteName;
NSURL *imageUrl = [NSURL URLWithString:album.thumbnail];
if (imageUrl == nil) {
self.albumThumbnail.image = [UIImage imageNamed:@"music_record"];
}
else {
self.albumThumbnail.imageURL = imageUrl;
}
}
the exception is
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance.
How do I do the check so that if the value retured is null, it uses a local image but if not null to use the image string url that is returned?