如何使用NSLog显示十六进制字节 [英] How to display hexadecimal bytes using NSLog

查看:127
本文介绍了如何使用NSLog显示十六进制字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 NSLog 显示以下字节?

How can I display the following bytes using NSLog?

const void *devTokenBytes = [devToken bytes];


推荐答案

假设 devToken 的类型为 NSData * (通过 bytes 调用),可以使用<$ c NSData上的$ c> description 方法可获取一个字符串,其中包含数据字节的十六进制表示形式。请参见 NSData类参考

Assuming that devToken is of type NSData * (from the bytes call), you can use the description method on NSData to get a string containing the hexadecimal representation of the data's bytes. See the NSData class reference.

NSLog(@"bytes in hex: %@", [devToken description]);

这篇关于如何使用NSLog显示十六进制字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆