I am using registerNib:forCellReuseIdentifier: to load cell from nib b/c I was told that with that I can always get a cell from [tableView dequeueReusableCellWithIdentifier:] and thus reduce those boilerplate codes.
I do always get a cell but the problem is that my IBAction (a button in my cell) started to fail by raising the exception 'NSInvalidArgumentException', reason: xxx unrecognized selector sent to instance.
If I remove the call registerNib:forCellReuseIdentifier: and add these codes as usual (below), everything works fine. So I guess the problem was caused by this call.
So what did I do wrong?
BTW, I set the file owner of my cell nib file to my table view controller. "Programming IOS 5" said "There is no need to specify a File’s Owner class in the nib" in this case, but since I need to set my IBAction I still set it. I don't think this will cause the problem, right ?
//The "old" codes without calling registerNib:forCellReuseIdentifier:
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"MyCell"];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MyCell"
owner:self
options:nil];
cell = [nib objectAtIndex:0];
...