Sometimes [responseObject valueForKeyPath:@"login"]
returns and array, sometimes it returns a dictionary. You need to test for this.
id loginValue = [responseObject valueForKeyPath:@"login"];
if ([loginValue isKindOfClass:[NSDictionary class]]) {
nome = [loginValue objectForKey:@"nome"];
email = [loginValue objectForKey:@"email"];
} else if ([loginValue isKindOfClass:[NSArray class]]) {
for (NSDictionary *retLogin in [responseObject valueForKeyPath:@"login"]) {
nome = [retLogin objectForKey:@"nome"];
email = [retLogin objectForKey:@"email"];
}
} else {
// ERROR: Unexpected value
}
When you have 1 value, then loginValue
is an NSDictionary. It contains {"EMAIL":"none","ID":"none","NOME":"none"}
.
When you have more than 1 value, then loginValue
is an NSArray. The array contains [<NSDictionary>, <NSDictionary>]
. Each of of these dictionaries contains {"EMAIL":"none","ID":"none","NOME":"none"}
.