views:

290

answers:

1
1 if (cell == nil) 
2 {
3    [[NSBundle mainBundle] loadNibNamed:@"TVCell" owner:self options:nil];
4    cell = tvCell;
5    self.tvCell = nil;
6  }

There's some code from an Apple example of using your own "custom cell XIB" to create cells in a UITableView.

It appears to work... but I think I would do better to actually UNDERSTAND what is being done there.

Why isn't line #3 assigning the value TO something?

cell = [[NSBundle mainBundle] loadNibNamed:@"TVCell" owner:self options:nil];

(In fact, cell and tvCell aren't being used at all.)

Why is line #4 assigning using tvCell when nothing has been put it in at all, yet?

Why is line #5 nulling out the tvCell that I need?

Why is "@property (nonatomic, assign) IBOutlet UITableViewCell *tvCell;" using assign, not retain?

About the only thing I can't get working correctly is when I put a disclosure-button on my custom cell XIB. Is there a way for me to detect when the user has clicked on it? (Hopefully, without using 100s of TAGs.)

+2  A: 

I haven't played with XIBs for cells, but I don't see why you couldn't still use tableView:accessoryButtonTappedForRowWithIndexPath:.

eman
That works just fine :)
willcodejavaforfood