if ([dict objectForKey:@"photo"] !=(id)[NSNull null])
{NSLOG(@"dictinary is not empty")}
Cela ne fonctionne pas pour moi. pour vérifier balise videiPhone Check dictionnaire vide
if ([dict objectForKey:@"photo"] !=(id)[NSNull null])
{NSLOG(@"dictinary is not empty")}
Cela ne fonctionne pas pour moi. pour vérifier balise videiPhone Check dictionnaire vide
Utilisez count
.
Par exemple:
if ([dict count] == 0) {
NSLog("empty");
}
Si vous voulez vérifier une clé alors:
if([dict objectForKey:@"photo"]) {
NSLog(@"There's an object in photo");
}
Si la objectForKey:@"photo"
est nulle quand pas présent, vous pouvez simplement faire: if ([dictionary objectForKey:@"photo"]) {NSLog(@"dictionary is not empty);}
essayer ce code pour vérifier est la valeur nulle ou non
NSString *value=[dict objectForKey:@"photo"];
if (value.length != 0)
{
NSLog("not empty!");
}
else
{
NSLog("empty!");
}
Ha! J'aime l'évitement flagrant d'une comparaison à «nul»! – CodaFi
J'ai pris dans la chaîne comme:
NSString *strPhoto=[dict objectForKey:@"photo"];
if (strPhoto ==(id)[NSNull null] || [strPhoto isEqualToString:@""] || strPhoto==nil || [strPhoto length]==0) {
}
Il travaille pour moi !!!!!!!!!!
Cela fonctionne pour moi. Vous pouvez gérer Null avec ce code.
[dict isKindOfClass:[NSNull class]];
La clé photo est une chaîne ou une valeur numérique? – Dinesh
tag est dans la chaîne – Tiger
c'est que je reçois photo = ""; – Tiger