How to display hexadecimal bytes using NSLog

前端 未结 2 1456
轮回少年
轮回少年 2021-02-19 20:43

How can I display the following bytes using NSLog?

const void *devTokenBytes = [devToken bytes];
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-19 21:14

    If you want a hex sequence:

    NSMutableString *hex = [NSMutableString stringWithCapacity:[devToken length]];
    for (int i=0; i < [devToken length]; i++) {
      [hex appendFormat:@"%02x", [devToken bytes][i]];
    }
    

提交回复
热议问题