views:

48

answers:

2

How can i get the computer's name in objective-c on a mac. I'm talking about the same name as the one you can find in System Profiler under software.

+2  A: 

NSHost is what you want here:

NSHost *host;

host = [NSHost currentHost];
[host name];
ennuikiller
Will that get be the user friendly name (so including things like spaces and apostrophes), or the dumber version where spaces are replaced with - and ' removed.
Jonathan
From the linked doc: `Can be either a simple hostname, such as @"sales", or a fully qualified domain name, such as @"sales.anycorp.com".`
invariant