Is it possible??

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

  1. arnieterm macrumors regular

    Aug 28, 2008
    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
  2. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    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


    Jul 18, 2008
    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