Re: What's the most cocoa-ey pattern for this?
Re: What's the most cocoa-ey pattern for this?
- Subject: Re: What's the most cocoa-ey pattern for this?
- From: j o a r <email@hidden>
- Date: Thu, 8 Jan 2009 16:56:19 -0800
On Jan 8, 2009, at 3:34 PM, Michael B Johnson wrote:
@property (readonly) NSMutableSet *activeMarkers;
You're right - it should be a set, not an array. But would it be
mutable if it's readonly? What are the correct semantics for that,
actually?
The "readonly" attribute only refers to the property itself, not the
mutability / immutability characteristics of that property, so it's
perfectly OK to have a readonly mutable property. That said, you
typically wouldn't expose a mutable collection through an interface
like that of course - it's a bit too promiscuous.
If performance allows, the easiest and most straight forward way to
implement this would be to have an immutable collection, and to
replace the entire collection whenever it changes. If you need better
performance or granularity, you can use a mutable collection, but you
need to ensure that you mutate the collection in such a way that you
get the KVO behavior that you need.
j o a r
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden