Re: Request for comments: Bindings to Class Objects
Re: Request for comments: Bindings to Class Objects
- Subject: Re: Request for comments: Bindings to Class Objects
- From: Thomas Lachand-Robert <email@hidden>
- Date: Sun, 22 Aug 2004 10:39:32 +0200
Le 22 ao{t 04, ` 05:51, mmalcolm crawford a icrit :
On Aug 21, 2004, at 2:05 AM, Thomas Lachand-Robert wrote:
Generally speaking, yes, but not in my case (see the code example).
Here I have a bunch of objects that not only use the value of the
global user pref, but also need to be notified whenever this value
changes. (A typical equivalent at the system level is the global
control tint: when changed by the user, the system sends
notifications and marks all windows for redraw.) This is why I need a
repository for the value. Or is there a better way?
Why not just register for NSUserDefaultsDidChangeNotification?
(There may be reasons why you might not want to do this, but that's
what I'd try first.)
That is also what I did first. But this is not very efficient, since
this notification has no object (not even the key that was whanged). So
every object interested in the change of only one preference has to
receive all notifications, and then decide if it is interested or not.
I then changed to register the classes objects for this notification,
which is obviously faster. (The class can check the preference, and
then tell its instances with a specific notification.) But then I tried
to bind directly the class to the user defaults controller, and it
works!
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.