• 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: readonly property which is a mutable array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: readonly property which is a mutable array


  • Subject: Re: readonly property which is a mutable array
  • From: David Duncan <email@hidden>
  • Date: Fri, 19 Nov 2010 10:05:20 -0800

On Nov 19, 2010, at 10:00 AM, Keary Suska wrote:

> So, I think we should write code to guarantee immutability to the caller, regardless of type of course, which is the API contract you spell out. I see the easiest way as always returning a copy in the getter. But I don't remember how synthesized accessors are implemented on the back-end, so I don't know if they do the smart thing by default...


If you require a mutability guarantee, it is always safe to create your own copy after the fact. Best case you were returned an immutable object and it is just a retain, worst case it was a mutable object that wouldn't have been modified anyway.
--
David Duncan

_______________________________________________

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: 
 >readonly property which is a mutable array (From: Remco Poelstra <email@hidden>)
 >Re: readonly property which is a mutable array (From: Keary Suska <email@hidden>)
 >Re: readonly property which is a mutable array (From: Ken Thomases <email@hidden>)
 >Re: readonly property which is a mutable array (From: Keary Suska <email@hidden>)

  • Prev by Date: Re: readonly property which is a mutable array
  • Next by Date: Re: Codesign failure
  • Previous by thread: Re: readonly property which is a mutable array
  • Next by thread: Re: On self = [super init...] ...
  • Index(es):
    • Date
    • Thread