Вместо того, чтобы встраивать четыре или пять функций в одну строку, вам нужно больше обрабатывать ошибки в своем коде.
Рассмотрим это вместо:
NSURL * referenceURL = [info objectForKey: UIImagePickerControllerReferenceURL];
if(referenceURL == NULL)
{
NSLog( @"reference URL is null");
} else {
NSData * imageData = [NSData dataWithContentsOfURL: referenceURL];
if(imageData == NULL)
{
NSLog( @"no image data found for URL %@", [referenceURL absoluteString] );
} else {
UIImage * theActualImage = [UIImage imageWithData: imageData];
if(theActualImage == NULL)
{
NSLog( @"the data at URL %@ is not an image", [referenceURL absoluteString] );
} else {
if(theImageView == NULL)
{
NSLog( @"I forgot to set theImageView" );
} else {
theImageView.image = theActualImage;
}
}
}
}
Надеюсь, эта информация поможет вам.