Hi All

 While working through chapter 21 - I was struck by the 'description' implementation on page 157 ...
  • (NSString *)description
    return [NSString stringWithFormat:@"<Employee %d: $%d in assets>", self.employeeID, self.valueOfAssets];

    Specifically the code ‘self.valueOfAssets’.

    I did a 'double take' and thought to myself - "Hmmm - I don't remember creating a @property for valueOfAssets'.  This can't be right - 'valueOfAssets' is an instance method and as such in needs to be sent as a message to self ...

    [self valueOfAssets].

    I double (and triple) checked that valueOfAssets was not a property - but the code still worked. I even created a dummy Foo object to recreate accessing a method with no arguments using dot notation - and it WORKED.

    I googled around a bit and discovered that it is possible to use dot notation to send a message that takes no arguments (like 'valueOfAssets' above) - but why would you ?  Its confusing.
    Interested in the opinion of others.


I have heard it said that while you can use dot notation you should really only use if for setters and getters. I recall a brief mention of this as well in the Stanford iOS class available via iTunes U. I believe this is to relieve the type of confusion you are expressing; however, it is not a language rule so it will work if used.

I hear you. There is definitely a lack of consistency in the book. So for the properties do dot notation. For the instance methods do a message call with the brackets [ ]. It’s easier if you make consistency a habit.