开发者

how to convert a path in NSString to CFURLRef and to FSRef*

开发者_开发百科

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜