Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-[__NSCFNumber isEqualToString] error

I'm getting this crash, but, in my code I am using a string. I've been working on this one piece of code for 2 hours now and I just can't see what I'm missing! Any ideas?

 NSString *codeR = [NSString stringWithFormat:@"%@", [[object objectForKey:@"code"] stringValue]];

    if([codeR isEqualToString:@"200"])

Error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x181cf0'

I would be very grateful input, this is confusing the hell out of me!

Thanks.

like image 715
NinjaLikesCheez Avatar asked Mar 06 '12 14:03

NinjaLikesCheez


1 Answers

Get rid of silly redundancy, see what happens.

NSString *codeR = [[object objectForKey:@"code"] stringValue];
// mysterious missing code
if ([coreR isEqualToString:@"200"]) // etc

Also, are you sure the error is raised from the if statement you posted? It could be coming from elsewhere.

like image 130
QED Avatar answered Nov 18 '22 16:11

QED