Last active
December 21, 2015 10:19
-
-
Save gekitz/6291259 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
const char *attributes = "T@\"DeliveryPlatform\",&,D,N"; | |
const char *ret; | |
char buffer[1 + strlen(attributes)]; | |
strcpy(buffer, attributes); | |
char *state = buffer, *attribute; | |
while ((attribute = strsep(&state, ",")) != NULL) { | |
if (attribute[0] == 'T') { | |
ret = (const char *)[[NSData dataWithBytes:(attribute + 3) length:strlen(attribute) - 4] bytes]; | |
} | |
} | |
NSLog(@"%s", ret); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ret is sometimes terminated and sometimes not, this only happens if the char* we pass in is 16 chars long. Note this only happens on iOS 6 and is not happening on iOS7 anymore, seems that Apple fixed it.