Trying to find line of code causing error please help!

Discussion in 'iOS Programming' started by mandude, Jan 11, 2011.

  1. mandude macrumors member

    Nov 19, 2009
    i'm getting a wonderful -[UIImageView scale]: unrecognized selector sent to instance 0x4b795e0 error I'm trying to find out what instance variable 0x4b795e0 is referring to. Is there a way to find the exact line of code causing this?
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    That error is a runtime exception. Check the Run > Stop At Objective C exceptions menu item. Run your app til you get the error. You'll see the stack trace and can find your code in it.

    It's also possible to use the Allocations Instrument to find what object a particular address refers to.

    Make sure to run Build and Analyze on your code first.

    This error is usually caused by an under-retain bug.
  3. mandude thread starter macrumors member

    Nov 19, 2009
    okay what is an under-retain bug? i released all the retained or allocated objects but i think this is happening because after switching between two views a round rect button i have isn't able to receive already released imageviews. how can i fix all this? i have no idea how to use the consul or the Instruments, I'd just like to find where the line of code is that's causing this or where i need to add code to fix this thanks for the help btw
  4. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Have you followed PhoneyDeveloper's advice and turned on the Run > Stop At Objective C Exceptions menu option and/or did a Build and Analyze? If so, what did you learn? If not, why not?
  5. chown33, Jan 12, 2011
    Last edited: Jan 12, 2011

    chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    An under-retain bug is similar to an over-release bug. Under-retain is what happens when you fail to retain something you should have. Over-release is what happens when you've called release too many times, or more likely, when you've released something you didn't own.

    You can fix this only by taking a systematic approach to finding the bug. Once you've found it, you can fix it.

    Instruments is an important debugging tool for memory management bugs like over-releasing. For example, you can enable zombies as one way to find over-releases. What are zombies?

    If you don't know how to use Instruments, now is a good time to learn.

    I know of no other effective way of finding bugs than to systematically apply appropriate tools and knowledge. The tools are there. The knowledge is there. It's up to you to acquire and apply them. You're the only person who has the code.

    Your only other alternative is to post all your code to some public uploadable website, whenever you have a bug you can't immediately find. Then you would post a complaint at some forum where you can throw yourself on the mercy and goodwill of others. As a debugging strategy, this will quickly become ineffective, at which point you'll have to learn Instruments and the debugger anyway.
  6. mandude thread starter macrumors member

    Nov 19, 2009

Share This Page