• 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: NSHomeDirectory() vs. -stringByExpandingTildeInPath
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSHomeDirectory() vs. -stringByExpandingTildeInPath


  • Subject: Re: NSHomeDirectory() vs. -stringByExpandingTildeInPath
  • From: j o a r <email@hidden>
  • Date: Mon, 28 Mar 2005 10:03:55 +0200


On 2005-03-28, at 09.15, Daniel DeCovnick wrote:

Mostly out of curiosity, which is better (ie, faster, more portable, cheaper) to use for creating a NSString for a file path somewhere in the current user's home directory, [NSHomeDirectory() stringByAppendingPathComponent:@"path/to/file.ext"]; or [@"~/path/to/file.ext" stringByExpandingTildeInPath];? And if they're the same for that case, are there cases in which it's better to use one than the other? Thanks.

The two cases you list should be functionally equivalent and equally portable. Usually you wouldn't have to think about the performance for a function like this one - it's not like you're going to do it 10.000 times per second, right?


It bears mentioning though that if you had used "-stringByStandardizingPath" instead of "-stringByExpandingTildeInPath " the resulting strings might be different because NSHomeDirectory() doesn't return a completely resolved path. If the path to the home directory contains symlinks they would be expanded in one case and not in the other. Both paths would be absolute, and correct, but still different.

j o a r

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: 
 >NSHomeDirectory() vs. -stringByExpandingTildeInPath (From: Daniel DeCovnick <email@hidden>)

  • Prev by Date: NSHomeDirectory() vs. -stringByExpandingTildeInPath
  • Next by Date: ObjectiveC++ strange warning at class declaration
  • Previous by thread: NSHomeDirectory() vs. -stringByExpandingTildeInPath
  • Next by thread: ObjectiveC++ strange warning at class declaration
  • Index(es):
    • Date
    • Thread