Le 15 mars 08 à 20:04, Kevin Dixon a écrit :
I'm trying to write a method that will convert a NSString containing a
file system URL to an FSRef with the following code

- (FSRef)stringToFSRef: (NSString*)filePath {
        FSRef output;

        CFStringRef cfFilePath = CFStringCreateWithCString(NULL, [filePath
cString], (CFStringEncoding)8);

        CFURLRef url = CFCreateURLWithString(NULL, cfFilePath, NULL);

        CFURLGetFSRef(url, &output);

        return output;
}

CFStringRef and NSString are tool-free bridged

you can do this:

CFURLRef url = CFCreateURLWithString(kCFAllocatorDefault, (CFStringRef)filePath, NULL);
And you must release it when done (even with GC)
CFRelease(url);

and NSURL and CFURL are tool free bridged, so can do this:

CFURLGetFSRef((CFURLRef)[NSURL URLWithString:filePath], &output);




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to