views:

99

answers:

2

Hi - I am receiving a EXC_BAD_ACCESS when I am presenting another controller in Modal view. Apparently, when I get to that controller's viewDidLoad, some variables are "invalid". However, if I wait like 20 seconds, then the controller will load fine.

I am new to iPhone. Sorry for a newbie question.

A: 

I wrote this blog about some techniques for tracking this down:

http://loufranco.com/blog/files/debugging-memory-iphone.html

The upshot is that you can run the application in a mode that will detect a lot of common memory problems.

Lou Franco
A: 

Often EXC_BAD_ACCESS can be tracked by just running the debugger. Don't set any break points, just run in debug (Command-Y) and do what you normally do to cause the app to crash. The debugger will stop at the place in the code where the crash is happening. You can then look at the threads list in the debugger (upper left view) and see the last line of your code that was valid. Lines that are in a gray font are lines from internal code. Lines in a full black font are your code. Click on the last (top most in the stack) of your lines of code and you can see where it's failing. You can then hover your mouse over the variables in that line to find the one that has not been initialized. This should give you and idea of what is happening.

Matt Long
Thank you Matt. I will try this and let you know what I find. Quick question - it appears that running my App in the Simulator versus a device yields inconsistencies. Do you have any insights? Thanks.
YVR1985
I've seen inconsistencies between the two before myself, but you'll have to elaborate on what inconsistencies you're seeing specifically.
Matt Long
Hi Matt - for example, the application would not have a fault with the NSString issue in the simulator as it would on the real phone. I have an app that is tracking scores, and in the simulator, I can enter the complete data I am requesting - fill up 5 arrays, about 10 variables, then store them in Core Data. No problem on the simulator but halts before I get even half way with the real device. Wierd. I am going to try your suggestion on both again see where the fault lies. At the end of the day, I wrote it so I should be able to figure it out. :-)
YVR1985