Hi all,

frankly my question is not really cocoa related, it is more regarding 
objective-c coding style, but still I'd like to hear the opinion of some 
professionals.

In order to reuse code I find it often very handy to write little "getters" 
which don't get their return value from an ivar but compute it somehow. I 
believe this is called derived property since it derives its value from other 
properties. My question is, what is the best style implementing such derived 
properties. With dot-notation in mind, I think the options are:

1. Only write the "getter"-method, no property, no sythesize, DON'T use 
dot-notation
2. Only write the "getter"-method, no property, no sythesize, DO use 
dot-notation
3. Write "getter"-method, write property (readonly, to justify dot-notation), 
sythesize

A basic question here is, for any method which might as well be a property and 
of course doesn't have any parameters, is it ok to use dot-notation or 
should'nt you do that.

Simple example:

- (BOOL)itemsSelected {
        return [myTableView selectedRow] != -1;
}

Regards,
Chris


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to