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

Re: Path to desktop


  • Subject: Re: Path to desktop
  • From: "Shawn Erickson" <email@hidden>
  • Date: Mon, 9 Jul 2007 10:37:47 -0700

On 7/9/07, Micha Fuhrmann <email@hidden> wrote:
Do I really need to reconstruct the full path with
stringByAppendingPathComponent ?

There's got to be something simple!!!

Any help very much appreciated.

Try the following (note -[NSString stringByExpandingTildeInPath] and -[NSString fileSystemRepresentation], the later should be used when passing a path to a POSIX API, etc.)...

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   NSArray* paths;
   paths = NSSearchPathForDirectoriesInDomains( NSDesktopDirectory,
NSUserDomainMask, NO );
   NSString* fullPathToDesktop = [[paths objectAtIndex:0]
stringByExpandingTildeInPath];
   const char* fullPathToDesktopFS = [fullPathToDesktop
fileSystemRepresentation];
   NSLog(@"NSDesktopDirectory:\n %@ [%s]", fullPathToDesktop,
fullPathToDesktopFS);

   [pool release];
   return 0;
}

On 7/9/07, Jim Turner <email@hidden> wrote:
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Desktop"];

That should do what you need.

You really should use NSSearchPathForDirectoriesInDomains or "drop" down to FSFindFolder.

-Shawn
_______________________________________________

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


  • Follow-Ups:
    • Re: Path to desktop
      • From: Chris Parker <email@hidden>
References: 
 >Path to desktop (From: Micha Fuhrmann <email@hidden>)
 >Re: Path to desktop (From: "Jim Turner" <email@hidden>)

  • Prev by Date: Re: How to keep creation/modification date of a (Core Data) object?
  • Next by Date: Re: How to keep creation/modification date of a (Core Data) object?
  • Previous by thread: Re: Path to desktop
  • Next by thread: Re: Path to desktop
  • Index(es):
    • Date
    • Thread