Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arnieterm

macrumors regular
Original poster
Aug 28, 2008
201
0
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
 

Cromulent

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
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

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.
 

xsmasher

macrumors regular
Jul 18, 2008
140
0
Finding the line the caused the crash -

Hi
Is it possible 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

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.