NSMutableData ne peut pas être lu
-
28-10-2019 - |
Question
NSMutableData *body = [NSMutableData data];
[body appendData:[self addFormData:@"username" withString:@"tom"]];
NSLog(@"-----the body is %@----", body);
Mais le NSLog affiche <0d345621 67543687 d123ab023 ........ etc>
J'ai pensé qu'il devrait afficher "username"="tom" tous ces trucs hexadécimaux, je veux dire que personne ne pourra le comprendre.
La solution
Convertir en une chaîne à utiliser / afficher, exemple:
NSString *str = [[NSString alloc] initWithData NSUTF8StringEncoding];
NSLog(@"str: %@", str);
Tenez compte du codage correct pour ces données - s'il s'agit d'une chaîne de caractères.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow