Reputation: 2078
How can I display the following bytes using NSLog?
const void *devTokenBytes = [devToken bytes];
Upvotes: 12
Views: 22500
Reputation: 32107
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]];
}
Upvotes: 9
Reputation: 60110
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]);
Upvotes: 16