Skip to content

Instantly share code, notes, and snippets.

@gekitz
Last active December 21, 2015 10:19
Show Gist options
  • Save gekitz/6291259 to your computer and use it in GitHub Desktop.
Save gekitz/6291259 to your computer and use it in GitHub Desktop.
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);
@gekitz
Copy link
Author

gekitz commented Aug 21, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment