I am using loadNibNamed:owner:options:
as documented by Apple to load a custom UITableViewCell from a nib file:
ItemCell *cell = (ItemCell *)[tableView dequeueReusableCellWithIdentifier:cellId];
if (cell == nil) {
// (1)
[[NSBundle mainBundle] loadNibNamed:@"ItemCell" owner:self options:nil];
// (2)
cell = self.itemCell;
self.itemCell = nil;
// (3)
// code continues here
}
And the class declaration of the view controller:
@interface MyViewController : UIViewController<UITableViewDelegate, UITableViewDataSource> {
@private
UITableView *tableView;
ItemCell *itemCell;
}
@property (nonatomic, retain) IBOutlet ItemCell *itemCell;
MyViewController is the File's Owner of the ItemCell.
I am observing the following:
self.itemCell
retain count is 0 self.itemCell
retain count is 2 self.itemCell
retain count is 0 cell
retain count is 1Could someone explain:
self.itemCell
retain count go from 2 to 0 between (2) and (3)?cell
in (3) equal to 1?As for the answer to your two questions, "implementation detail".
As long as you balance your retains and releases, your job is done. Explaining why the retain count is any given absolute value would require access to the implementation of the frameworks themselves.