Programming Style - Challenge related


So I ended up with two solutions for the challenge, which made me question if there is a reason/situation that you’d use one over the other.

What am I doing differently by referencing myComputer.localizedName vs [myComputer localizedName]?

Are either of these statements “more proper”? Or more proper in a specific situation?

NSHost *myComputer = [NSHost currentHost];
NSLog(@"'%@' is the name of my computer", myComputer.localizedName);        

NSHost *myComputer = [[NSHost alloc]init];
NSLog(@"'%@' is the name of my computer", [myComputer localizedName]);

I found enough information on the alloc/init portion of the question and in this case the currentHost direct reference is preferred (although it sounds like it doesn’t really matter these days?).


They look different because of the syntax, but they are equivalent in function.

See: The Objective-C Programming Language, “Declared Properties.”


Thank you!

And should have known…just got to chapter 17 and there it said it explicitly!