nilay neeranjun
nilay neeranjun

Reputation: 145

Property not being recognized in custom cell

Here is my CustomCoordinatesCell.h file:

#import <UIKit/UIKit.h>

@interface CoordinatesCustomCell : UITableViewController
@property (weak, nonatomic) IBOutlet UILabel *index;

@property (weak, nonatomic) IBOutlet UILabel *latitude;

@property (weak, nonatomic) IBOutlet UILabel *longitude;
@end

However, in my CustomCoordinatesCell.m file, when I use @synthesize for latitude and longitude for example, @synthesize latitude = _latitude, this works. However, when I try this for the index property, it gives me an error:

Property implementation must have its declaration in interface 'CoordinatesCustomCell'

However, the property for index IS in my CoordinatesCustomCell.h file

Here is my CustomCoordinateCell.m file:

#import "CoordinatesCustomCell.h"

@implementation CoordinatesCustomCell
@synthesize latitude = _latitude;
@synthesize longitude = _longitude;
@synthesize index = _index;

//@synthesize coordinateNumber = _coordinateNumber;
- (void)awakeFromNib {
// Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

@end

Upvotes: 1

Views: 43

Answers (1)

Paulw11
Paulw11

Reputation: 114836

You no longer need @synthesize statements.

You have accidentally declared your cell as subclassing UITableViewController rather than UITableViewCell.

Also make sure that you declare and cast your cell correctly in order to access its custom properties:

CustomCoordinateCell *cell = (CustomCoordinateCell *)[tableview dequeueReusableCellWithIdentifiee:identifier forIndexPath:indexPath];

Upvotes: 4

Related Questions