我正在检查此字典中的项目(从服务器返回)是否为 NULL,如下所示:
NSString *imageURL = [userDict objectForKey:@"image_url"];
NSString *userName = [userDict objectForKey:@"username"];
NSString *typeName = [userDict objectForKey:@"type"];
if (imageURL == NULL || userName == NULL || typeName == NULL || imageURL.length == 0) {
localImage = [UIImage imageNamed:@"first.png"];
[addAnnotation setTitle:@"Something"];
[addAnnotation setSubTitle:@"Wrong"];
}
但是,在一条记录中(上面是在 for 循环中)[userDict objectForKey:@"image_url"]
返回"<null>"
但在上面的 if 语句中没有得到正确处理。为什么我的空检查不起作用?