I need to use several functions requiring CFURLRef and FSRef* and for the moment I just have a path stored in an NSString. What is the (most efficient) way to perform this conversion?
Thanks in advance for your help,
A path can be easily converted to a CFURL by using NSURL, which it is toll-free bridged with. There is also a CFURL function which will give you a FSRef for it. This code will give you both, given an NSString named thePath.
CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:thePath];
FSRef fileRef;
CFURLGetFSRef(url, &fileRef);
If you already have a valid pointer to a FSRef
, you can pass it to CFURLGetFSRef
directly.
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