Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6635559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:04:12+00:00 2026-05-25T23:04:12+00:00

I recently discovered a pretty big performance issue in my app that was due

  • 0

I recently discovered a pretty big performance issue in my app that was due to an image not being found in [UIImage imagenamed:].

I was wondering if there is a “drop-in” solution to have this kind of ‘errors’ logged in some way? I started writing an extension to the UIImage class, something like this:

@implementation UIImage (Debug)
#ifdef DEBUG
+ (UIImage*) imageNamed:(NSString*) name{
    UIImage* img = [UIImage imageNamed:name];

    if(!img){
        NSLog(@"Error: referencing non-exiting image: %@", name);
    }

    return img;
}
#endif
@end

But this causes an endless loop since [UIImage imageNamed:name] of course causes the extension method to be called again…

Any suggestions?

thanks
Thomas

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:04:13+00:00Added an answer on May 25, 2026 at 11:04 pm

    You should never use categories to override an existing method. This will lead to unexpected results (the implementation used will depend on the order the runtime loads the binary images/modules).

    Instead, you may use the possibilities of the objc runtime to exchange implementations of one selector with another (sometimes called method swizzling). But I would discourage you to do this if you don’t really know the implications. (call the swapped method if you want to call the original to avoid call loops, manage the use case when the method is implemented in the parent class but not the child, and much more subtleties)


    But if you only want to debug and be alerted when an UIImage is not found use symbol breakpoints ! (Breakpoints are not limited to be placed on a given line of code!)

    Breakpoints are more powerful than you can imagine (I encourage you to watch the WWDC’11 video session about “mastering debugging in Xcode”), especially you can place a breakpoint not on a specific line in your code, but on a specific method call (in your case the method -imageNamed:), and add a condition to the breakpoint so it will only be hit in certain condition (returned image nil?). You can even ask the breakpoint to log some info (or play a sound, or whatever) and/or continue execution instead of stopping your code execution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We recently discovered that the Google Maps API does not play nicely with SSL.
I recently discovered at work that it is the policy not to use compiler
I've discovered something pretty amazing that works recently. I am wanting to know if
I recently discovered that the java.lang.String.substring method does not return a new string, but
I recently discovered that if a UITextField is being edited in a controller that's
I've recently discovered that my app malfunctions on Win 7 machines because it does
We've got a pretty typical django app running on postgresql 9.0. We've recently discovered
I recently discovered that when you have a page set to session readonly and
I recently discovered that I can use lambdas to create simple event handlers. I
I recently discovered that a sql query that was running fine earlier is now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.