I have implemented a custom table cell and get a runtime error ("Unrecognized selector sent to instance") when the table enters cellForRowAtIndexPath. An error occurs when trying to create an instance of a custom cell. I have achieved this successfully before, but now the error will not go away. I have a prtotype cell, and its own class attribute is set to a custom element of a subclass of UITableViewCell. Here is the user cell:
#import "FavoriteCell.h" @implementation FavoriteCell @synthesize lblGaugeID, lblMainTitle, bgImage; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { bgImage = [UIImage imageNamed:@"tableCellBG.png"]; self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { UIColor *transparentBG = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0]; UIColor *foregroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
and here it is initialized (issued from my view controller class):
-(FavoriteCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *cellIdentifier = @"favoriteCell"; FavoriteCell *cell = (FavoriteCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
Here is the complete error message:
* Application termination due to the uncaught exception "NSInvalidArgumentException", reason: '- [__ NSCFConstantString instantiateWithOwner: options:]: unrecognized selector sent to instance 0x24bb0'
Can anyone advise what to check? Thank you Vivian
source share