Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

zippyfly

macrumors regular
Original poster
Mar 22, 2008
141
0
I am confused by the Apple documentation for low-level file handling:

http://tinyurl.com/q5bzo3

For the example:

Code:
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"MyFile.txt"];

I just want the home directory, and not appending anything to it.

I tried

Code:
NSString *path = [NSHomeDirectory()];

but Xcode gives an error of expecting : before ] and so I take it is expecting some parameter to be passed.

I tried passing an empty string literal @"", and it worked, but surely that is not the right way to do it (?)

Clicking on the hyperlink for NSHomeDirectory gives a fairly useless description:

NSHomeDirectory

Returns the path to the current user’s home directory.

NSString * NSHomeDirectory (void);

Return Value

The path to the current user’s home directory.
Discussion

For more information on file-system utilities, see Low-Level File Management Programming Topics.
Availability

* Available in Mac OS X v10.0 and later.

See Also

* NSFullUserName
* NSUserName
* NSHomeDirectoryForUser

Related Sample Code

* Quartz Composer WWDC 2005 TextEdit

Declared In
NSPathUtilities.h

Please advise where I should be looking, because I have tried searching in all the usual places (including option+double clicking) and the docs are not helpful.

Thanks!
 
NSHomeDirectory is a function that returns a NSString*. You have placed the call to the function in square brackets indicating that you want to pass a message to that object but not supplied a message to pass. That's exactly what XCode has told you

You just want:
Code:
NSString *path = NSHomeDirectory();
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.