You should never use categories to override an existing method . This will lead to unexpected results (the implementation used will depend on how the runtime loads binary images / modules).
Instead, you can use the capabilities of the objc runtime to exchange implementations of one selector with another (sometimes called the swizzling method ). But I would discourage you from doing this if you really don't know the meaning . (call the swap method if you want to call the original to avoid calling cycles, control use-case, when the method is implemented in the parent class, but not in the child device, and much more subtleties)
But , if you only want to debug and receive warnings when UIImage is not found, use character breakpoints ! (Breakpoints are not limited to placing on a given line of code !)
Breakpoints are more powerful than you can imagine (I recommend you see the WWDC'11 session on “mastering debugging in Xcode”), especially you can place a breakpoint not on a specific line of your code, but on calling a specific method (in your In the case of the -imageNamed: method, and add the condition to the breakpoint , so it will only get in a certain state (the image is nil?) You can even request a breakpoint to register any information (or play a sound or something else) and / or continue execution instead of stopping code execution.
AliSoftware
source share