ccfstring

Convert a CFStringRef to a C string?


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!


Solution

  • 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];