Skip to content

Instantly share code, notes, and snippets.

@emarashliev
Created February 5, 2014 15:52
Show Gist options
  • Save emarashliev/8826629 to your computer and use it in GitHub Desktop.
Save emarashliev/8826629 to your computer and use it in GitHub Desktop.
From CFStringRef to C string
CFStringRef eventStr = CFSTR("Hello, I'm an event.");
CFIndex length = CFStringGetLength(eventStr);
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
char *event = (char *)malloc(maxSize);
CFStringGetCString(eventStr, event, maxSize,kCFStringEncodingUTF8);
printf("Event %s\n", event);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment