August 11, 2009 0

When to use dot notation?

By admin in Uncategorized

In Objective-C from my understanding.
[NSOnedayInstancedrink drink:*Beer];
Is the same as:
NSOnedayInstancedrink.drink = *beer

Why the difference, well from what I’ve been reading, you want to use a @property versus bracket notation in these use-case scenarioes:
* Use @property to declare the state exposed by your objects.
* Use dot notation to get and set objects’ state.

* Use method declarations to declare the behavior exposed by your objects.
* Use bracket notation to invoke objects’ behavior.


The idea is to separate STATE from BEHAVIOR. For example NSOnedayInstancedrink.drink = *beer is a state, where as [NSOnedayInstance consumeDrink:*beer is a behavior.

Tags: , , ,

Leave a Reply

Powered by WP Hashcash

Spam protection by WP Captcha-Free