Updates

NSMutableString.alloc.init

I have been doing objective-c programming for a while, and have been using dot notation mainly for getters and setters. This was mainly due to the memory management it brought with it when using properties before Automatic Reference Counting. I looked at it a bit closer and was surprised to see that you can use dot notation for methods as well. My friend Josh warned me that it was bad style and could end up killing kittens if I used dot notation for anything besides getters and settings.

I had been doing this in Ruby, but had a faint memory about how it had to be a instance variable and not a method for objective-c. Playing around with it, I found you can do crazy stuff like:

NSMutableString *test=NSMutableString.alloc.init;

and you would think you could do something like this:

test.appendString(@“something”);

but that gives you a compiler error about appendString not being a property. Which is weird, given that alloc and init are not properties. So it all comes back full circle when I realize that dot notation is really all about getters and setters. The implementation allows you to do some strange things, but doesn’t make it right. Kittens saved.

This posting goes over it in more detail:

http://qualitycoding.org/dot-notation/