我正在使用电子邮件搜索NSString以查找@字符。这是代码:
NSRange range = [string rangeOfString:@"@"];
if (range.location != NSNotFound) // do stuff
这是我得到的错误......
-[__NSCFNumber rangeOfString:]: unrecognized selector sent to instance 0x1e51c550
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber rangeOfString:]: unrecognized selector sent to instance 0x1e51c550'
答案 0 :(得分:4)
您的string
变量指向NSNumber
的实例,而不是NSString
的实例。您正在初始化它。