iOS NSJSON Retour null
-
12-11-2019 - |
Question
J'ai le code suivant
hostStr = [hostStr stringByAppendingString:post];
NSData *dataURL = [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]];
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];
NSError *error = nil;
NSDictionary *result = [NSJSONSerialization
JSONObjectWithData:dataURL
options:kNilOptions
error:&error];
NSArray *files = [result objectForKey:@"GV_Return"];
NSLog(@"Files: %@", files);
// For Each Key we seperate the data and add it to an object to be used.
for (NSDictionary *file in files)
{
NSString *userNumber = [result objectForKey:@"UserNumber"];
NSLog(@"output: %@", userNumber);
}
Le problème que j'ai, c'est que Nslog (@ "files:% @", fichiers); Renvoie ce que j'attends
Files: (
{
UserNumber = 1;
}
)
Cependant Nslog (@ "output:% @", UserNumber); Retour NUL
J'ai besoin d'aide pour déterminer pourquoi nsstring * userNumber = [résultat objectforkey: @ "userNumber"]; Ne semble pas revenir "1" comme il se doit.
Pas de solution correcte
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow