I’m working on an iPad app in which I have a table view. When the user selects a row in the table, I use didSelectRowAtIndexPath to open a popover. I’m getting an error message saying “message sent to deallocated instance” when I try to use a certain button. I originally though the errors was getting thrown by the popover (in it’s viewDidLoad or something), so I put a breakpoint in and stepped through the code. To my surprise, I was able to step all the way through the loading of the popover and the rest of the didSelectRowAtIndexPath on my table view (which actually just involves stepping out of some if blocks). The error then gets thrown when I get a couple steps into the automatically generated code that doesn’t appear in any of my class files (that looks like 0x0010d71d <+1164> mov 0x6...).
So, my question is, how do I find where this error is being thrown? Is there another method that is automatically run after didSelectRowAtIndexPath that could be getting messed up somewhere?
Okay, everyone’s responses lead me to find malloc error -[CFString release], which helped me figure out I had a string in my popover that I alloc in
viewDidLoadbySince I alloc it this way, it gets set to autorelease. The problem was I was explicitly
[myString release];andmyString = nil;inviewWillAppear. Removing thereleaseand=nilparts cleaned up my error.To answer the actual question that I posted, I believe the
autoreleasewasn’t firing until the simulator actually tried to display the popover (which would run afterdidSelectRowAtIndexPath). Since that occurs after I explicitly[myString release]inviewWillAppear, it was trying toautoreleasesomething that was no longer there. Just to reiterate, the proper way to do it was let itautoreleaseat the end, and not[myString release]anywhere in my code.Can someone verify that this is correct? As I mentioned in my comments, I’m still very new to iOS development. I have a feeling at the end of this project, I’m going to be able to go back to first stuff I did in it and make dozens of improvements in terms of doing things more efficiently and more in accordance with best practice.