Re: Bindings
Re: Bindings
- Subject: Re: Bindings
- From: Rick Bischoff <email@hidden>
- Date: Sat, 19 Jun 2004 17:09:40 -0500
Hi,
Thanks for the speedy reply, much appreciated.
I did as you suggested and put an +initialize method in the document
class-- and it worked (as in the program didn't halt with the error
message "Can't find selector named PercentageConverter")
But.... the text field does not behave as I would expect. I had to
uncheck "Conditionally Allows Editable" in the value binding to even
allow me to change the value. When I did that, if I attempted to
change the value in the Exchange Rate box:
-[PercentageConverter reverseTransformedValue:]: selector not recognized
Even though I have the "allowsReverseTransformation" set to always
return NO. So, I added a reverseTransformationValue method to the
PercentageConverter class and all was good. Works perfect.
So, why do I need to set the reverseTransformedValue method? Does the
"valueConverter" normally work from the Model -> View and not vice
versa?
Rick Bischoff
Blog, and home for some MacOS X apps --
http://rickjr.org
On Jun 19, 2004, at 4:53 PM, Louis C. Sacha wrote:
Hello...
If you are editing the document's nib, then the FileOwner will usually
be an instance of your NSDocument subclass. I think the instructions
you are refering to are talking about the main nib for the
application, usually MainMenu.nib, where the FileOwner is the
NSApplication instance.
If you have a main controller for the application (you don't
necessarily need one) you can make the delegate connection to
FileOwner (the NSApplication instance) in the main nib, and register
the value transformer in that class.
If you only use your value transformer in the interface for that
particular type of document (or subclasses), then you could add an
+initialize method to your document class that registers the value
transformer, since the +initialize method for your document class will
always be called before the document's nib is loaded.
The point of doing it in the class/instance of the the application's
delegate is to register the value transformer as soon as the app is
launched, which ensures that the value transformer will be loaded
early enough no matter how it is used. The only requirement is to make
sure that the value transformer is registered before it gets used
anywhere, so in this case, doing it in the +initialize method of the
Document class would probably be sufficient.
Hope that helps,
Louis
_______________________________________________
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.
References: | |
| >Bindings (From: Rick Bischoff <email@hidden>) |
| >Re: Bindings (From: "Louis C. Sacha" <email@hidden>) |