Hello lovely computer people:
I would like to convert the following CFStringRef into a CString. Any idea how?
recordFilePath = (CFStringRef)[NSTemporaryDirectory() stringByAppendingPathComponent: @"recordedFile.wav"];
Thanks!
EDIT 1
DarkDust answer seems to come close, but I'm still getting an error (see comment). Any help?
A straightforward solution:
CFStringGetCString(myCFStringRef, myCStringPointer, mySize, myEncoding);
Checkout this function:
Boolean CFStringGetCString (
CFStringRef theString,
char *buffer,
CFIndex bufferSize,
CFStringEncoding encoding
);
Since a CFStringRef
can be toll-free casted to NSString
, you can simply do:
myCString = [(NSString *)myCFStringRef UTF8String];
or in your case:
myCString = [[NSTemporaryDirectory() stringByAppendingPathComponent: @"recordedFile.wav"] UTF8String];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With