Re: readonly property which is a mutable array
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