the better way is to implement the indexed accessors described in the KVC doc.

in fact I know at least one engineer would would like the doc to specifically say that you should NOT have an accessor that returns an array like this.


On Jun 26, 2008, at 7:54 PM, Stuart Malin wrote:

Separately, I have an accessor -attendees: of the Party class, which is currently implemented as:

- (NSArray*) attendees
{
return [NSArray arrayWithArray:attendees]; // "attendees" is an NSMutableArray, and is an ivar
}

I intentionally do not return the underlying mutable array, because I don't want other code accessing the content without going through the accessors.

Is my implementation reasonable? Or are there preferable ways to do this (such as to return a copy of the mutable array)?

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to