I am writing an app in iOS 6. This is a snippet of code from ViewController.m file:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"CustomCellIdentifier"];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
cell = _customCell;
_customCell = nil;
}
cell.firstName.textLabel = @"dsdsds";
cell.middleName.textLabel = @"N/A";
cell.lastName.textLabel = @"daasdsdasa";
return cell;
}
These lines of code give me error (Property 'firstName' not found on object of type 'CustomCell*'
):
cell.firstName.textLabel = @"dsdsds";
cell.middleName.textLabel = @"N/A";
cell.lastName.textLabel = @"daasdsdasa";
CustomeCell.h:
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *firstName;
@property (strong, nonatomic) IBOutlet UILabel *middleName;
@property (strong, nonatomic) IBOutlet UILabel *lastName;
+(NSString*) reuseIdentifier;
@end
In the Outlets of CustomCell.xib:
firstName -> label
middleName -> label
lastName -> label
Referencing Outlets:
customCell -> File's Owner
Selecting the firstName label:
Referencing Outlets:
firstName -> CustomCell
firstName -> CustomCell -CustomCellIdentifier
Selecting the middleName label:
lastName -> Custom Cell - CustomCellIdentifier
middleName -> Custom Cell
Selecting the lastName label:
lastName -> Custom Cell
middleName -> Custom Cell- Custom Cell Identifier
So, what is the prob? In my opinion it has something to do with Outlets.