nilay neeranjun nilay neeranjun - 1 year ago 73
Objective-C Question

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;

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


Answer Source

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];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download