• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What's the most cocoa-ey pattern for this?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >What's the most cocoa-ey pattern for this? (From: Michael B Johnson <email@hidden>)
 >Re: What's the most cocoa-ey pattern for this? (From: j o a r <email@hidden>)
 >Re: What's the most cocoa-ey pattern for this? (From: Greg Titus <email@hidden>)
 >Re: What's the most cocoa-ey pattern for this? (From: Michael B Johnson <email@hidden>)

  • Prev by Date: Re: NSDecimalNumber seen as NSCFNumber; a bug?
  • Next by Date: Re: Encryption and Security
  • Previous by thread: Re: What's the most cocoa-ey pattern for this?
  • Next by thread: Re: What's the most cocoa-ey pattern for this?
  • Index(es):
    • Date
    • Thread