PDA

View Full Version : how to convert CFString to c++ string




chidambaram
Apr 8, 2008, 07:02 AM
hi,

I am working in a carbon c++ application using XCode.

How can i convert CFString to c++ string?

thanks in advance and urgent plz...



robbieduncan
Apr 8, 2008, 07:25 AM
Use one of the well document functions like this (http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html#//apple_ref/c/func/CFStringGetCString) to turn it into an array of characters then convert that to a C++ String object?

lee1210
Apr 8, 2008, 07:28 AM
http://paste.lisp.org/display/5105

This will get you a char *, the step from there to std::string is short. There may be a more direct way, but this should work. I'd make a function that returns a string that does all that.

-Lee