__NSCFNumber isEqualToString:的问题.--[__NSCFNumber isEqualToString:]: unrecognized selector sent to in(转)
__NSCFNumber isEqualToString:的问题.--[__NSCFNumber isEqualToString:]: unrecognized selector sent to in
-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x7c2680b0
解析服务器返回的状态码,如果直接跟字符串对比的话,会出现这个错误。网上说将isEqualToString改成isEqual,果然不报错了,但是匹配返回的布尔值跟预期的不一样。
果断将得到数据,再次用nsstring包装下,然后还是用isEqualToString来进行匹配,答案是正确的。
[AFNetworkingTool postWithUrl:urlString
params:params
success:^(id response) {
NSLog(@"会议签到数据 responseObject = %@",response);
NSString *code = [response objectForKey:@"status"];
NSString *codeStr = [NSString stringWithFormat:@"%@",code];
BOOL ok = [codeStr isEqualToString:@"200"];
if (ok) {
NSMutableArray *array = [response objectForKey:@"datas"];
complation(array);
}else{
NSMutableArray *array = [[NSMutableArray alloc]init];
[array addObject:@"error"];
complation(array);
}
} fail:^(NSError *error) {
NSLog(@"会议签到 error = %@",error);
}];