I came across a little gotcha today cause by a habit of using @property (nonatomic, retain) for object properties. The problem in this case was a UITableView controller that was refusing to be deallocated because its reference count would never reach 0.
I eventually tracked down the problem to my custom table view cell object which had the following property:
AppTableView *table; // Subclassed UITableViewController
@property (nonatomic, retain) AppTableView *table;
and when using the table view cell I was doing
cell.table = self; // reference back to the table
What this meant however was that because the cell had now retained the UITableViewController the controller could never be deallocated, because to release the cells required the controller to deallocate but the controller could not deallocate because the cells have not been released. Catch 22.
The solution was to change the retain to assign and remove the [table release] from the cells dealloc method:
@property (nonatomic, assign) AppTableView *table;
// Weak reference to table view