Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failing to register custom subclasses of UITableViewCell

I have two custom subclasses of UITableViewCell that Xcode doesn't like. I'm trying to call the registerClass:forReuseIdentifier: method like so:

static NSString* gameCellIdentifier = @"GameCell";
static NSString* buttonCellIdentifier = @"ButtonCell";
// Register the classes for use.
[self.tableView registerClass:ButtonCell forCellReuseIdentifier:buttonCellIdentifier];
[self.tableView registerClass:GameCell forCellReuseIdentifier:gameCellIdentifier];

And I'm getting the error, "Unexpected interface name ... expected expression instead." error. Any ideas?

like image 983
Logan Shire Avatar asked Jun 02 '13 23:06

Logan Shire


2 Answers

You need to send a Class to registerClass:forCellReuseIdentifier: so you need to do this:

[self.tableView registerClass:[ButtonCell class] forCellReuseIdentifier:buttonCellIdentifier];
[self.tableView registerClass:[GameCell class] forCellReuseIdentifier:gameCellIdentifier];

Good luck !

like image 75
Daniel Avatar answered Nov 14 '22 22:11

Daniel


Never mind, I figured it out. I just needed to do [ButtonCell class] instead.

like image 20
Logan Shire Avatar answered Nov 15 '22 00:11

Logan Shire