Re: KVC and KVO for arrays
Re: KVC and KVO for arrays
- Subject: Re: KVC and KVO for arrays
- From: Adam P Jenkins <email@hidden>
- Date: Wed, 13 Feb 2008 16:57:01 -0500
On Feb 13, 2008, at 4:30 PM, mmalc crawford wrote:
It's not clear why you're making things more complicated than
necessary.
Just uses indexed accessors.
The above will not work unless you're using garbage collection...
I don't think my example is complicated at all. In fact leaving out
the indexed accessors makes my Party class trivially simple. I do
agree that in a production app I'd probably just bite the bullet and
add indexed accessors. I'm just demonstrating that you don't need to
implement them, because the array proxy that mutableArrayValueForKey:
returns will do the work for you if you follow the right conventions.
It is a little fragile, because if you later added accessor methods to
the Party class for the attendees property, it would revert to copying
the array on each modification.
As for your GC comment, you're probably right that my code leaks
without GC turned on. Since I got Leopard, I've gotten into the
habit of just enabling GC for all my projects, and haven't looked
back. I do realize this makes my programs unable to run on previous
versions of OSX, and that if I was writing commercial Mac software I
might not make that choice. But I enjoy programming much more when
the language I'm using has GC, and since my Mac programming is all
just hobby stuff I don't mind if it won't run on pre-Leopard systems.
Adam
_______________________________________________
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