I've got an app that gets information from a SOAP web service and I want to display the results in a UITableView
.
I had a previous version of this app and I'm creating a new version to basically clean things up and get rid of a bunch of legacy code that's deprecated and no longer used.
In the previous version, this worked well. In the new version, not so much.
Basically, the current scenario is returning 3 strings that I'm trying to use as the basis for the data in my UITableView
.
I'm struggling with this issue because it's so stinkin' hard to track down EXC_BAD_ACCESS
errors!
(Parenthetically, if someone has a way to make the debug experience more like Visual Studio, I'd love to hear it! It's so frustrating to not have any idea which line caused the error, and also to not be able to look through my local variables at the time of the crash to see what's what. I've already added in the exception breakpoint, but that doesn't seem to do much.)
Anyway, the line that's causing the error APPEARS to be:
return [[self Libraries] count];
It occurs in tableView:numberOfRowsInSection:
.
The error message I get APPEARS to reference a string that should be stored in the NSMutableArray
[self Libraries]
.
What's going on here?
I'm using ARC, so shouldn't all of my memory management be correctly handled?
I don't have any manual release statements in my code ANYWHERE!
Please help me fix this!
ARC relies on the Apple standard/recommended naming practices. Check that you are not violating any of them.
Just for starters, if "
Libraries
" is an instance there are are naming issues.Set NSZombieEnabled, MallocStackLogging, and guard malloc in the debugger. Then, when your App crashes, type this in the gdb console:
Replace
0x543216
with the address of the object that caused the crash, and you will get a much more useful stack trace and it should help you pinpoint the exact line in your code that is causing the problem.See this article for more detailed instructions.
OK, so I feel a little bit silly, but I've got two production machines. On one of them, I had installed a copy of Xcode 4.2 beta alongside the final, production copy. I forgot to uninstall the beta copy and was using it to run my code. As soon as I cleared that up and ran my code against the final, released Xcode 4.2, all works fine again.
As I mentioned to Jonathan Grynspan above, I DO understand Obj-C memory management. For some reason, I was getting a retain/release/release (performed by ARC), and that bug is remedied in the final version.
Thanks for the help in tracking this down! At least I got a definitive answer to WHY the problem existed!