I'm getting a crash when running on an iOS6 device but NOT an iOS 7 device. I have a custom UITableViewCell
with a xib LanguageCell.xib. It has 2 labels, a button, and a view. I have a class LanguageCell where I have 4 IBOutlets:
@interface LanguageCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *titleLbl;
@property (strong, nonatomic) IBOutlet UIButton *buyButton;
@property (strong, nonatomic) IBOutlet UILabel *saleLbl;
@property (strong, nonatomic) IBOutlet UIView *separatorLine;
I have connected all 4 views to their properties so the connections pane looks like this:
When I run the app, I get a crash when loading this table:
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<LanguageCell 0x1f5160c0> setValue:forUndefinedKey:]: this class
is not key value coding-compliant for the key buyButton.'
Why am I getting this problem on iOS6 but not iOS7?
EDIT: I should add that the Custom Class is set properly on the xib
EDIT 2:
When I clear all the IB connections and run the code, the line if ([currentObject isKindOfClass:[LanguageCell class]])
returns false when it should be true, thus cell
remains nil
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
LanguageCell *cell = (LanguageCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"LanguageCell" owner:nil options:nil];
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[LanguageCell class]])
{
cell = (LanguageCell *)currentObject;
break;
}
}
}
I use the same exact code for 3 other tables in my app and it works just fine. I don't understand why this one is giving me problems.