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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.