Reputation: 44310
I'm doing this in dealloc of a view
[baseTable release];
In the header file, I declare it like this:
IBOutlet UITableView *baseTable;
....
@property(nonatomic, retain) UITableView *baseTable;
For some reason, I get a "EXC_BAD _ACCESS" in the dealloc. When I comment out the above line, all is well. How can I determine what specifically is going on with the UITableView and release?
Upvotes: 1
Views: 2419
Reputation: 1501
when you are using the property Retain put the check if
if(self.tableView!=nil)
{
self.tableView = nil;
}
in dealloc.In this way you are checking whether the table view is nil and is it is nil you are making it into nil.
Upvotes: -1
Reputation: 39690
If you want to find out the exact reason for the EXC_BAD_ACCESS bug, enable NSZombie, so that any time you call any method on a deallocated object, it tells you exactly what object and what method it is.
To enable NSZombie:
To disable it, either delete the value or uncheck it if you may want to turn it on again later. Be sure to not leave it on, because it doesn't actually deallocate anything when enabled!
Upvotes: 4
Reputation: 9982
Sounds like you're over-releasing baseTable
. It's hard to say where that might be happening without seeing more of your code. Are you giving ownership of that table to the autorelease pool at any point? When you autorelease an object, you're transferring ownership to the autorelease pool and you need to be sure to abandon the object (and possibly nil
out its instance variable).
You need to examine every use of baseTable
and make sure that any object that might assume ownership of the table retains it before releasing it. Also remember that you may be referencing the table object through an alias as a parameter to a UITableViewDelegate
or UITableViewDataSource
method.
Upvotes: 1
Reputation: 39750
My guess is that you are releasing baseTable one too many times somewhere, have a look for a place where you are releasing it with out retaining.
You must have one and only one release for every retain, start from there and see how you go. The tricky bit is making sure that wherever you pass the baseTable object the release/retain match up. So it won't be as simple as a grep on [ baseTable release ] and count them unfortunately :)
Upvotes: 1