Created
June 17, 2016 16:16
-
-
Save wess/ad6da41fb52c731f0c47781c7ffcb497 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 *)stringFromHexString:(NSString *)hexString { | |
| if (([hexString length] % 2) != 0) | |
| return nil; | |
| NSMutableString *string = [NSMutableString string]; | |
| for (NSInteger i = 0; i < [hexString length]; i += 2) { | |
| NSString *hex = [hexString substringWithRange:NSMakeRange(i, 2)]; | |
| unsigned int decimalValue = 0; | |
| sscanf([hex UTF8String], "%x", &decimalValue); | |
| [string appendFormat:@"%c", decimalValue]; | |
| } | |
| return string; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment