Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone NSMutableData无法读取_Iphone_Nsmutabledata - Fatal编程技术网

Iphone NSMutableData无法读取

Iphone NSMutableData无法读取,iphone,nsmutabledata,Iphone,Nsmutabledata,但是NSLog显示 我认为它应该显示“username”=“tom”所有那些十六进制的东西,我的意思是没有人能够理解它。转换为字符串以供使用/显示,例如: NSMutableData *body = [NSMutableData data]; [body appendData:[self addFormData:@"username" withString:@"tom"]]; NSLog(@"-----the body is %@----", body); 确实要考虑对这个数据正确的编

但是NSLog显示


我认为它应该显示“username”=“tom”所有那些十六进制的东西,我的意思是没有人能够理解它。

转换为字符串以供使用/显示,例如:

 NSMutableData *body = [NSMutableData data];

[body appendData:[self addFormData:@"username" withString:@"tom"]];

 NSLog(@"-----the body is %@----", body);

确实要考虑对这个数据正确的编码——如果它是字符串的话。< /P>它是“数据”——字节。您需要将其放入NSString中才能打印字符。我建议您改为

NSUTF8StringEncoding
?当然,在这种情况下它是不相关的,但是UTF8应该总是优先于ASCII。@Tom,当然,
NSUTF8StringEncoding
是我通常使用的,并且已经改变了我的答案!但我不得不做出选择,并认为
NSASCIIStringEncoding
可能是这里最好的选择。
NSString *str = [[NSString alloc] initWithData NSUTF8StringEncoding];
NSLog(@"str: %@", str);