你在用到isEqualToString的地方先判断这个数据的类型
NSString *str;
if ( [object isKindOfClass:[NSNumber Class]])
{
str = [object stringValue];
}
else if ([object isKindOfClass:[NSString Class]])
{
str = object;
}
然后再进行你的[ str isEqualToString:...]...操作
NSLog(@"%@",[responseObject objectForKey:@"errorCode"]);
NSString *str;
if ( [[responseObject objectForKey:@"errorCode"] isKindOfClass:[NSNumber class]])
{
str = [[responseObject objectForKey:@"errorCode"] stringValue];
if ([str isEqualToString:@"9997"]) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"9997" forKey:@"errorCode"];
}
}else if ([[responseObject objectForKey:@"errorCode"] isKindOfClass:[NSString class]])
{
str = [responseObject objectForKey:@"errorCode"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"9997" forKey:@"errorCode"];
}