mercredi 24 juin 2015

UITableViewCell subclass throwing an unrecognized selector sent to instance

My UITableViewCell is giving a -[UITableViewCell nameTeam]: unrecognized selector sent to instance.

I created a PlayerStatsTableViewCell.xib with a UITableViewCell and UILabel. Set the Custom Class to "PlayerStatsTableViewCell" and its Table View Cell identifier to "playerStats"

PlayerStatsTableViewCell.h

@interface PlayerStatsTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *nameTeam;
@end

PlayerStatsTableViewCell.m

@implementation PlayerStatsTableViewCell
@synthesize nameTeam;

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

In my PlayerStatsTableViewController, cell.nameTeam is throwing the error

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PlayerStatsTableViewCell *cell = (PlayerStatsTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"playerStats"];
    [tableView registerNib:[UINib nibWithNibName:@"PlayerStatsTableViewCell" bundle:nil] forCellReuseIdentifier:@"playerStats"];

    cell.nameTeam.text = @"PLEASE";

    return cell;
}

See more ..

Aucun commentaire:

Enregistrer un commentaire