if ([dict objectForKey:@"photo"] !=(id)[NSNull null])
{NSLOG(@"dictinary is not empty")}
这对我不起作用。检查空标签
if ([dict objectForKey:@"photo"] !=(id)[NSNull null])
{NSLOG(@"dictinary is not empty")}
这对我不起作用。检查空标签
使用count
.
例如:
if ([dict count] == 0) {
NSLog("empty");
}
如果要检查密钥,则:
if([dict objectForKey:@"photo"]) {
NSLog(@"There's an object in photo");
}
这对我有用。您可以使用此代码处理 Null。
[dict isKindOfClass:[NSNull class]];
如果objectForKey:@"photo"
不存在时为空,您可以这样做:if ([dictionary objectForKey:@"photo"]) {NSLog(@"dictionary is not empty);}
试试这个代码检查是否为空值
NSString *value=[dict objectForKey:@"photo"];
if (value.length != 0 )
{
NSLog("not empty!");
}
else
{
NSLog("empty!");
}
我已经接受了这样的字符串:
NSString *strPhoto=[dict objectForKey:@"photo"];
if (strPhoto ==(id)[NSNull null] || [strPhoto isEqualToString:@""] || strPhoto==nil || [strPhoto length]==0) {
}
它对我有用!!!!!!!!!!