[NSCFNumber isEqualToString:]: unrecognized selector sent to instance [NSCFNumber isEqualToString:]: unrecognized selector sent to instance ios ios

[NSCFNumber isEqualToString:]: unrecognized selector sent to instance


return [NSString stringWithFormat:@"%@",[self.hours objectAtIndex:row]];


You are returning an NSNumber as that is what is held in self.hours. As NSString is the expected return value you should create a string via:

[NSString stringWithFormat:@"%@", [self.hours objectAtIndex:row]];

or reevaluate your intent. Did you actually want to store indices in this way, or did you want to store NSStrings?


If anyone is having this problem and specifically returning an index of a row, then you can always convert the NSNumber to a stringValue by doing the following:

NSString *code = [[[JSONResponse objectForKey:@"meta"] objectForKey:@"code"] stringValue];

Placing a stringValue at the end of the method will convert anything to a string, you can also use intValue.