开发过程中遇到的bug,代码为:
NSDictionary *test = @{@"1":@"1", @"2":@(NO), @"3": @(1.1)};
//这里第一行会报错
NSLog(@"%@",[[test objectForKey:@"1"] stringValue]);
NSLog(@"%@",[[test objectForKey:@"2"] stringValue]);
NSLog(@"%@",[[test objectForKey:@"3"] stringValue]);
原因是因为从字典里取出的value如果为string格式,那么就不可以调用stringValue方法了。