How to display hexadecimal bytes using NSLog

gabac picture gabac · Sep 14, 2010 · Viewed 20.5k times · Source

How can I display the following bytes using NSLog?

const void *devTokenBytes = [devToken bytes];

Answer

Tim picture Tim · Sep 14, 2010

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]);