For ObjC, I have the choice to use either dot notation or square bracket notation. Is there a way to enforce (with errors/warnings) a certain notation for uniform notation throughout a project?
Perfectly valid question. Not sure why the downvotes.
When we designed @property
, the dot came along with it. There was considerable debate about whether the dot should be limited to @property
or not. We landed on "not" because there was too much pre-existing API that kinda sorta felt like a property but would never be re-declared as an @property
because it really wasn't.
NSArray
's -count
is an obvious one. That could easily be @property
. But then there are methods that fall more into the gray area.
Didn't seem like there was enough value to really warrant enforcing such a rule, hence .
was presented as (nearly) identical with calling a getter or setter.
The compiler didn't have an option to enforce one or the other then. And I'm pretty darned sure-- but not 100% certain-- it hasn't grown one since.