0
votes

I am using a custom cell to display information. When I pass the information to UILabel using NSString I am getting following error.

Error:

[HITEstimationCustomViewCell isEqualToString:]: unrecognized selector sent to instance 0x6892f80

2012-10-23 01:38:04.821 MyApp[13298:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[HITEstimationCustomViewCell isEqualToString:]: unrecognized selector sent to instance 0x6892f80

Cell Details:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"EstimationCellIdentifier";

    static BOOL nibsRegistered = NO;

    if(!nibsRegistered)
    {
        UINib *nib = [UINib nibWithNibName:@"HITEstimationCustomViewCell" bundle:nil];

        [tableView registerNib:nib forCellReuseIdentifier:CellIdentifier];

        nibsRegistered = YES;
    }


    HITEstimationCustomViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    NSUInteger row = [indexPath row];
    NSString *rowData =[estimationListArray objectAtIndex:row];

    cell.nameTextField = rowData;
    cell.emailIdTextField = [estimationListArray objectAtIndex:row];

return cell;
'

Instance:

HITEstimationCustomViewCell *newCell = [[HITEstimationCustomViewCell alloc] initWithNameField:@"Michael" emailId:@"[email protected]" skypeId:@"mrmike" hourlyRate:@"$25" numberOfHours:@"20" totalCost:@"$1000"];

    NSMutableArray *myArray = [[NSMutableArray alloc] initWithObjects:newCell, nil];

self.estimationListArray = myArray;

Interface:

@interface HITEstimationCustomViewCell : UITableViewCell

@property (weak, nonatomic) IBOutlet UILabel *nameField;
@property (weak, nonatomic) IBOutlet UILabel *totalCost;
@property (weak, nonatomic) IBOutlet UILabel *hourlyRate;
@property (weak, nonatomic) IBOutlet UILabel *emailId;
@property (weak, nonatomic) IBOutlet UILabel *skypeId;
@property (weak, nonatomic) IBOutlet UILabel *numberOfHours;

@property (copy, nonatomic) NSString *nameTextField;
@property (copy, nonatomic) NSString *totalCostTextField;
@property (copy, nonatomic) NSString *hourRateTextField;
@property (copy, nonatomic) NSString *emailIdTextField;
@property (copy, nonatomic) NSString *skypeIdTextField;
@property (copy, nonatomic) NSString *numberOfHoursTextField;


-(id)initWithNameField:(NSString *)name emailId:(NSString *)email skypeId:(NSString *)skype hourlyRate:(NSString *)hourlyPrice numberOfHours:(NSString *)Hours totalCost:(NSString *)total;


@end

Implementation:

@implementation HITEstimationCustomViewCell

@synthesize nameField;
@synthesize totalCost;
@synthesize hourlyRate;
@synthesize emailId;
@synthesize skypeId;
@synthesize numberOfHours;

@synthesize nameTextField;
@synthesize totalCostTextField;
@synthesize hourRateTextField;
@synthesize emailIdTextField;
@synthesize skypeIdTextField;
@synthesize numberOfHoursTextField;



-(void)setNameTextField:(NSString *)n
{
    if(![n isEqualToString:nameTextField])
    {
        nameTextField = [n copy];

        nameField.text = nameTextField;
    }
}


-(id)initWithNameField:(NSString *)name emailId:(NSString *)email skypeId:(NSString *)skype hourlyRate:(NSString *)hourlyPrice numberOfHours:(NSString *)Hours totalCost:(NSString *)total
{

    self = [super init];
    if(self)
    {

        self.nameTextField = name;
        self.emailIdTextField = email;
        self.skypeIdTextField =skype;
        self.hourRateTextField = hourlyPrice;
        self.numberOfHoursTextField = Hours;
        self.totalCostTextField = total;

    }

    return self;
}

I am very new to IOS & XCode and have been trying alot of things found on forums but haven't been able to fix the issue.

1
Please don't shout at us. We stackoverflowians spook easily. - Wug

1 Answers

2
votes

The error message tells you everything you need to know:

[HITEstimationCustomViewCell isEqualToString:]: unrecognized selector sent to instance
       ^                              ^
       Class Name                     Method Name

You're calling isEqualToString: on an instance of HITEstimationCustomViewCell.

Look at where you call isEqualToString: and work backwards. You'll see that you're assigning an HITEstimationCustomViewCell instance to the nameTextField property, instead of an NSString.