Skip to content

Instantly share code, notes, and snippets.

@ajonnet
Created June 22, 2014 09:10
Show Gist options
  • Save ajonnet/5636f2df933971ca9f3d to your computer and use it in GitHub Desktop.
Save ajonnet/5636f2df933971ca9f3d to your computer and use it in GitHub Desktop.
Generates Hexadecimal String from given instance of NSData. ex. "0A:1B:CC"
-(NSString *) NSStringHexFormatFromData:(NSData *) data
{
Byte *bytes = (Byte *)data.bytes;
NSMutableString *str = [[NSMutableString alloc] init];
for (int i =0; i<data.length; i++) {
[str appendFormat:@"%02X",bytes[i]];
if (i!= (data.length -1)) {
[str appendString:@":"];
}
}
return [NSString stringWithString:str];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment