Error: CUICatalog: Invalid asset name supplied: (null), or invalid scale factor : 2.000000
This one appears when someone is trying to put nil
in [UIImage imageNamed:]
Add symbolic breakpoint for [UIImage imageNamed:]
Add $arg3 == nil
condition on Simulator, $r0 == nil
condition on 32-bit iPhone, or $x2 == nil
on 64-bit iPhone.
Run your application and see where debugger will stop.
P.S. Keep in mind this also happens if image name is empty string. You can check this by adding [(NSString*)$x2 length] == 0
to the condition.
This error (usually) happens when you try to load an image with [UIImage imageNamed:myImage]
but iOS is not sure if myImage
is really a NSString
and then you have this warning.
You can fix this using:
[UIImage imageNamed:[NSString stringWithFormat:@"%@", myImage]]
Or you can simply check for the length
of the name of the UIImage
:
if (myImage && [myImage length]) { [UIImage imageNamed:myImage];}
Since the error is complaining that the name you gave is (null)
, this is most likely caused by calling [UIImage imageNamed:nil]
. Or more specifically, passing in a variable hasn't been set, so it's equal to nil
. While using stringWithFormat:
would get rid of the error, I think there's a good chance it's not actually doing what you want. If the name you supply is a nil
value, then using stringWithFormat: would result in it looking for an image that is literally named "(null)", as if you were calling [UIImage imageNamed:@"(null)"]
.
Something like this is probably a better option:
if (name) { UIImage *image = [UIImage imageNamed:name];} else { // Do something else}
You might want to set a breakpoint in Xcode on that "Do something else" line, to help you figure out why this code is getting called with a nil value in the first place.