NSData转化成十六进制字符串
Byte *bytes=(Byte*)[data bytes];
NSString *hexStr=@"";
for(int i=0;i<[data length];i++)
{
NSString *newHexStr=[NSString stringWithFormat:@"%x",bytes[i]&0xff];///16进制数
if([newHexStr length]==1)
hexStr=[NSString stringWithFormat:@"%@0%@",hexStr,newHexStr];
else
hexStr=[NSString stringWithFormat:@"%@%@",hexStr,newHexStr];
}
NSLog(@"bytes的16进制数为:%@",hexStr);
如果只是输出查看的话,可以
for(int i=0;i<[data length];i++)
printf("%x ",bytes[i]);
printf("\n");