I'm missing something here


I completely understand the following code, and this was my first approach at completing the Challenge.

NSHost *myMac = [NSHost currentHost];
NSString *localizedName = [myMac localizedName];

NSLog etc. etc. etc.

What I am missing is the relevance of “+ (NSHost *)currentHost” from the NS Class Reference and the cooresponding “- (NSString *) localizedName”. Upon reading that I was totally confused about how to build the code that I thought I already understood, and wasted a bunch of time fooling around and going down dead ends. The more research I did, the more confused I got. Am I missing something other than a regular “ClassMethod” and “InstanceMethod” approach here?

What am I missing ?


So, the method currentHost (declared with a +) is a class method – you execute it by sending the message currentHost to the class NSHost. (And the method returns an instance of NSHost)

The method localizedName (declared with a -) is an instance method – you execute it by sending the message localizedName to an instance of NSHost.

Does that help?


So that is describing the way the method is declared in the header file, and we then know from experience how to utilize it in the code itself. It’s slowly sinking in…