Is it possible??

Discussion in 'iOS Programming' started by arnieterm, Oct 15, 2008.

  1. arnieterm macrumors regular

    Joined:
    Aug 28, 2008
    #1
    Hi
    Is it ppossible to get the exact location where an error occurs? My Iphone application hang up in simulator but I am not able to find out where error occurs. When I step by step debug the app, it works fine but as soon as I press "continue execution", the app hangs.
    I think there must be at least one thing in XCode IDE that will help you find the place where error occurs
    Thanks
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Breakpoints. Use them.

    Make a note of all the variables and make sure they contain the correct values. There are all kinds of things that can cause a crash.
     
  3. xsmasher macrumors regular

    xsmasher

    Joined:
    Jul 18, 2008
    #3
    Finding the line the caused the crash -

    NSLog(@"Hi there"); is handy - it lets you know what lines are being reached, which will help narrow the problem.

    But to answer your question - yes, there is a way to see what line the debugger stopped on:
    When your app crashes, go to Run > Debugger.
    You'll see on the left of that window the "stack" of current method calls.
    #0 at the top is probably inside the OS, not in your code - so click down the list until you see some of your code.
    The pane on the right will show the variables that are currently defined at that point in the stack, and you can check them out for strangeness.

    Note this won't work for all kinds of errors. Also, you still have some work to do - the line your crashed on may not be the "bad" line; maybe you forgot to retain or do an assignment in an earlier line of code.
     

Share This Page