How to check if an image exists in the Xcode Asset Catalog?

I receive JSON data via HTTP and want to display it in MKMapView using custom MKAnnotationView. So no problem so far.

The bad thing is that the REST service can return contact types that do not have equivalents in my .xcassets file. Is there any way to check the entry in the Application Catalog and avoid such messages:

CUICatalog: Invalid asset name: NonExistingImage or invalid scale factor: 2.000000

Example current code:

NSString * imageName = @"NonExistingImage";

if (imageName != nil) {
    // this line creates the above message
    UIImage * image = [UIImage imageNamed:imageName]; 

    // checking for image != nil, otherwise use default image
} else {
    // default image
}
+4
source share
1 answer

: , imageNamed NSString ( nil), . , UIImage NO.

+2

All Articles