I provided a UITableViewCell subclass MyCell with outlet properties (in order to hook up the nib):
@interface MyCell : UITableViewCell
@property (nonatomic, strong) IBOutlet UILabel* theLabel;
@end
I then synthesize theLabel.
I then want to use the property name to access the cell:
MyCell *theCell = (MyCell *)cell;
UILabel *lab = theCell.theLabel;
When I use the property name to access the cell I receive an error message:
[UITableViewCell theLabel]: unrecognized selector
I seem to be missing something. Why does it throw an exception?
Your problem is that within your cellForRowAtIndexPath function you are not correctly instantiating the cell to your “MyCell” type but rather just trying to static cast the pointer to it. In the end you trying to access a property that doesn’t exist in a plain UITableViewCell.
Are you loading your cell similar to this?: