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]];
存在しないときに nullの場合は、次のobjectForKey:@"photo"
ことができます。if ([dictionary objectForKey:@"photo"]) {NSLog(@"dictionary is not empty);}
このコードを試して、チェックがnull値かどうかを確認してください
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) {
}
それは私のために働いています!!!!!!!!!!!!