• 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: API Path Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: API Path Question


  • Subject: Re: API Path Question
  • From: Ricky Sharp <email@hidden>
  • Date: Mon, 12 Jun 2006 15:45:18 -0500

On Jun 12, 2006, at 1:41 PM, Nick Zitzmann wrote:


On Jun 12, 2006, at 8:22 AM, Jerrod Fowkes wrote:

NSString* theURL = @"/Users/useronfilesystem/documents/u i.yui";
CFStringRef escapedURL = nil;
escapedURL = CFURLCreateStringByAddingPercentEscapes (kCFAllocatorDefault,
(CFStringRef)theURL, NULL, NULL, kCFStringEncodingUTF8);


CFURLRef anURL = nil;
anURL = CFURLCreateWithString(NULL, escapedURL, NULL);
CFStringRef filePath = nil;
filePath = CFURLCopyFileSystemPath(anURL, kCFURLHFSPathStyle);

I think you're making this too difficult. Try something like this instead:


NSURL *theURL = [NSURL fileURLWithPath:@"/Users/useronfilesystem/ documents/u i.yui"];
NSString *filePath = (NSString *)CFURLCopyFileSystemPath((CFURLRef) theURL, kCFURLHFSPathStyle);
// do stuff here...
[filePath release];

When working with standard folders, it's best to use something like this:


NSArray* theSearchPaths = NSSearchPathForDirectoriesInDomains (
    NSDocumentDirectory, NSUserDomainMask, YES /* expand tilde */);

NSString* thePrimaryPath = [theSearchPaths objectAtIndex:0];
NSString* theFilePath = [thePrimaryPath stringByAppendingPathComponent:@"u i.yui"];



Then you can do the CFURLCopyFileSystemPath.

Note that depending upon the needs, you'll want to specify different options for the "directories in domains" call. Also, you may want to handle the case where multiple paths can be returned.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: API Path Question (From: Jerrod Fowkes <email@hidden>)
 >Re: API Path Question (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: Object for variable array of fixed structures
  • Next by Date: Re: IB: Maintaining bindings when copying controls
  • Previous by thread: Re: API Path Question
  • Next by thread: Validation of NSTextField contents
  • Index(es):
    • Date
    • Thread