FROM : Jean-Daniel Dupas
DATE : Sat Mar 15 20:25:19 2008
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);
DATE : Sat Mar 15 20:25:19 2008
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);
| Related mails | Author | Date |
|---|---|---|
| Kevin Dixon | Mar 15, 20:04 | |
| Adam R. Maxwell | Mar 15, 20:23 | |
| Jean-Daniel Dupas | Mar 15, 20:25 | |
| Keith Duncan | Mar 15, 20:34 | |
| Adam R. Maxwell | Mar 15, 20:48 | |
| Stuart Malin | Mar 16, 07:49 | |
| stephen joseph but… | Mar 16, 09:11 | |
| Nir Soffer | Mar 16, 10:41 | |
| Jean-Daniel Dupas | Mar 16, 12:09 | |
| Jens Alfke | Mar 16, 16:35 | |
| Stuart Malin | Mar 16, 18:09 | |
| Michael Ash | Mar 16, 19:15 | |
| Adam R. Maxwell | Mar 16, 19:38 | |
| Kevin Dixon | Mar 17, 16:44 | |
| Sean McBride | Mar 17, 17:27 |






Cocoa mail archive

