5

I am fetching JSON data via HTTP and want to display them in a MKMapView with a custom MKAnnotationView. So no problem until here.

Bad thing is the REST service could return types of pins that don't have equivalents in my .xcassets file. Is there any way to check for an entry in the App's Asset Catalog and avoid messages like this:

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

Current code example:

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
}
3
  • 1
    Good question. It could boiled down to "How to check if an image exists in XCode Asset Catalog?".
    – tilo
    Feb 25, 2014 at 8:50
  • Thanks. Corrected the title ;)
    – mvoelkl
    Feb 25, 2014 at 11:06
  • Is there any reason to get rid of that message? It doesn´t seem to be harmful, since an invalid asset name just returns nil, no exception.
    – TAKeanice
    Feb 25, 2014 at 11:36

1 Answer 1

3

My solution: Seems you call imageNamed with an empty NSString (or nil) this info is being logged. If the image passed simply doesn't exist, resulting UIImage is nil and NO message is created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.