Re: Getting the name of the current user
Re: Getting the name of the current user
- Subject: Re: Getting the name of the current user
- From: "John C. Randolph" <email@hidden>
- Date: Thu, 30 Aug 2001 20:02:22 -0700
On Thursday, August 30, 2001, at 07:46 PM, Serge Meynard wrote:
Is there an API in Cocoa (or Carbon I guess) to get the name of the
current
user under OS X? Searching the apple docs got me nothing.
Try:
NSString *userName = NSUserName();
And if you want the full name, you can use NSFullUserName();
I suppose I could expand the home directory path and extract the last
component using NSString, but that feels like an ugly hack...
That doesn't get you the user's name, it just gets you the name of his
home directory. Not necessarily the same thing.
Tip: when searching the docs, don't forget the Foundation and AppKit
functions! There's a lot of handy code in there that people tend to
re-write because they never looked for it.
-jcr
"Scientology is evil; its techniques are evil; its practice is a serious
threat to the community, medically, morally, and socially; and its
adherents are sadly deluded and often mentally ill... --Justice
Anderson, Supreme Court of Victoria, Australia