Created
June 22, 2014 09:10
-
-
Save ajonnet/5636f2df933971ca9f3d to your computer and use it in GitHub Desktop.
Generates Hexadecimal String from given instance of NSData. ex. "0A:1B:CC"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(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