Re: When/how to use bindings (was Re: MVC question)
Re: When/how to use bindings (was Re: MVC question)
- Subject: Re: When/how to use bindings (was Re: MVC question)
- From: John Timmer <email@hidden>
- Date: Sun, 08 Feb 2004 17:48:59 -0500
>
I would be very interested in hearing from anyone who is adopting
>
bindings in an existing application. How easy has the process been;
>
what have been the major obstacles (if any); what have been the main
>
benefits (I assume there are some! :-) .
I found bindings to be very useful for live updating of information display.
I've got one window that displays some information, and a preferences window
that controls how some of that information is formatted. Because of the
annoyance of checking each control of the prefs window for changes and
sending that information on to the display window, I previously had an
"apply" button that sent all changes at once.
Bindings allowed me to simply have any changes go directly to the user
defaults. The window's controller watches the necessary values in the user
defaults, and updates immediately in response. I get live updating, and its
cut down dramatically on the object references I have to pass around within
the application.
The one hassle I had was with a font value. Getting an NSFont from the
NSFontPanel and sending it to the user defaults turned out to be much, much
harder than it really should be. The Font Panel's been designed exclusively
for updating text in an editing field, when there are clearly uses for it
elsewhere.
Writing custom formatters and value transformers turned out to be very
little hassle, and most of the ones I made look like they could be useful in
the future. There were lots of other little bits of code to change in the
window controller, but in every case, it involved simplifying and cutting
out lines of code.
One thought that occurred to me during this process was that someone with
some server space would do the community a service by hosting a collection
of formatters and value transformers. I can't imagine I'm the only one who
has needed and made a ZIP code formatter or font to user defaults value
transformer, so being able to download one with an appropriate source code
license would have saved a little time.
Cheers,
JT
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.