Cocoa Binding Musings
Cocoa Binding Musings
- Subject: Cocoa Binding Musings
- From: Craig Hockenberry <email@hidden>
- Date: Mon, 10 May 2004 11:11:25 -0700
I should begin by stating that the new Cocoa Binding technology is truly
amazing -- it's cut my development time considerably. To all those involved,
thank you!
Now, what follows are various things that I still don't understand or had
problems understanding in the month or two that I've been working with
bindings. Searches of the Apple list archives haven't proved useful, so if
these topics have been covered previously, please blame it on Mamasam.com
being down and out...
1) How does one localize the placeholder text in the value binding? My first
guess of it being a key for an entry in Localizable.strings proved wrong. It
seems unlikely that a German user will want to see "Please enter text" for a
null placeholder.
2) I can't figure out how to remove a key from a NSUserDefaultsController.
For example:
id values = [[NSUserDefaultsController sharedUserDefaultsController]
values];
[values setValue:nil forKey:@"whatever"];
won't work on a text field or anything else that relies on NSString. Using
removeObjectForKey: or setNilValueForKey: don't work either.
revertToInitialValues: is too broad in scope.
A similar problem exists for controls bound to NSData (and archived NSImage,
for example.)
Basically, how does one "reset" a control that has no initial value?
3) It took me forever to figure out what the default value transformers
"NSIsNil", "NSIsNotNil", etc. did. Searching the Reference Library & Google
turned up nothing. By chance, I stumbled upon "NSIsNilTransformName" the
other day and it answered my question. Why does the documentation not match
IB? Why doesn't a search on developer.apple.com not match the "NSIsNil"
pattern?
4) If File's Owner in IB is set to NSApplication, and the delegate is
connected to a class that supports KVC, the delegate never gets passed
get/set invocations. Obviously, you can work around this by creating a
separate NIB with File's Owner set to your class (alleviating the need to
have a delegate), but it's a pain for small applications. It seems like the
delegate should be able to handle the KVC on behalf of NSApplication. Am I
missing something, or is this a bug?
5) Text fields only update user defaults after the user has pressed the
enter key. (It's possible that this is true for other controls -- I think
I've seen this behavior in table cells.)
This seems like a bug from a HIG point-of-view -- if a user types "abc" into
a text field and then closes the application, the fact that they typed "abc"
is never recorded in the user defaults. Of course, you can track
controlTextDidChange: and update the model yourself, but that seems like a
lot of work for something I feel should be the standard behavior.
6) Shouldn't there be an easy way to get a case insensitive sort from IB. I
realize that you can set up sort descriptors to get caseInsensitiveCompare:
instead of compare: -- but since views of the filesystem are common, it
would be nice to have some easy way to configure this directly in the NIB.
7) I have yet to find an easy way (e.g. no code) to "reset" a value which is
bound to another control. It would be VERY nice to have a capability where
pressing a button would cause a slider to go to a specified value (think
reset.) Or where some user action filled in a form with preset values. Or...
Being able to write as well as read (in the context of Interface Builder)
could be very powerful.
In closing, these are all fairly minor things (or feature requests.) The
only bad thing I can say about Cocoa Bindings is that it takes quite awhile
to wrap your head around it. The fact that it's quick to get started was
very helpful and made me see benefits almost immediately. This list is
essentially my "where I've hit the wall" in the past couple of months of
heavy usage -- not bad at all for a new technology!
-ch
_______________________________________________
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.