Re: Design Question: Where to observe using KVO?
Re: Design Question: Where to observe using KVO?
- Subject: Re: Design Question: Where to observe using KVO?
- From: Patrick Mau <email@hidden>
- Date: Fri, 11 Jul 2008 09:45:34 +0200
Ken Thomases wrote:
> How about a dictionary whose keys are NSValues representing the
> objects? For each object, the value from the dictionary would be an
> NSMutableArray whose elements are the key paths being observed on that
> object.
>
> // ...
> NSValue* objectKey = [NSValue valueWithNonretainedObject:object];
> NSMutableArray* keyPaths = [observers objectForKey:objectKey];
> if (!keyPaths)
> {
> keyPaths = [NSMutableArray array];
> [observers setObject:keyPaths forKey:objectKey];
> }
> [keyPaths addObject:keyPath];
Hi Ken
Do you think that observing lots of objects with lots
of keypaths is a good idea anyway?
Maybe I'm considering my first approch again, using only key-value
coding inside the view and move the observing somewhere else ...
What I like about your idea is the use of
[NSValue valueWithNonretainedObject:object];
I didn't know that. I'm quite new to coocoa, but not to programming.
Since the number of keypaths for each object is constant, I might
decide using a custom bitmap object as the value part in the
dictionary. That bitmap would indicate which keypath is being observed.
Thanks a lot.
Patrick
_______________________________________________
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