• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Convert NSString to FSRef
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert NSString to FSRef


  • Subject: Re: Convert NSString to FSRef
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sat, 15 Mar 2008 20:25:19 +0100


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 (email@hidden)

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:
This email sent to email@hidden


References: 
 >Convert NSString to FSRef (From: "Kevin Dixon" <email@hidden>)

  • Prev by Date: Re: Convert NSString to FSRef
  • Next by Date: Re: Convert NSString to FSRef
  • Previous by thread: Re: Convert NSString to FSRef
  • Next by thread: Re: Convert NSString to FSRef
  • Index(es):
    • Date
    • Thread