Re: Bindings: is there a better way to observe when an object changes?
Re: Bindings: is there a better way to observe when an object changes?
- Subject: Re: Bindings: is there a better way to observe when an object changes?
- From: Simone Tellini <email@hidden>
- Date: Mon, 10 Sep 2007 20:15:09 +0200
Il giorno 10/set/07, alle ore 19:55, Charles Steinman ha scritto:
--- Simone Tellini <email@hidden> wrote:
I've created an NSView subclass which needs to be
redrawn every time
an entity object changes, where "changes" means that
any of its
attributes change.
I've added an "hasChanged" attribute to the entity
and made it
dependent on all the other keys, using -
setKeys:triggerChangeNotificationsForDependentKey:
[SNIP]
I don't like this solution very much, though (for
instance, I need to
remember to update the hasChanged dependancies if I
add/remove an attribute).
This is the normal solution as far as I know. If you
really want *all* attributes of the entity to trigger
the notification, you could just get them from
NSEntityDescription rather than listing them yourself,
but you're pretty much doing it the normal way. Out
NSEntityDescription is 10.4+, apart from that it could have been what
I was looking for.
I tried using -attributeKeys from NSClassDescription, but it always
returned nil.
are you finding any other problems with this approach?
no, it works fine. I just don't think that it's very elegant ;-)
Anyway, I think that I'm doing the only possible thing at the moment,
so I'll stop wasting my time on it.
Thanks everyone.
--
Simone Tellini
http://tellini.info
_______________________________________________
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