Re: Bindings
Re: Bindings
- Subject: Re: Bindings
- From: "Louis C. Sacha" <email@hidden>
- Date: Sat, 19 Jun 2004 14:53:16 -0700
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
Hello,
I just completed the tutorial
(http://developer.apple.com/documentation/Cocoa/Conceptual/
CurrencyConverterBindings/index.html#//apple_ref/doc/uid/TP40001095)
on Cocoa bindings and am trying to convert the text field for the
"Exchange Rate" such that it:
1. Displays the number as a percentage (done)
2. Uses the actual decimal value in the bindings (i.e., divide the
number in the box by 100)
So I created a "Value Transformer" class, but since this is a
"Document Based Cocoa App", I have no idea how/where I should
register the transformation at. The docs say to use..
[NSValueTransformer setValueTransformer:etcetcetc]
In the "initialize:" class message (or in
applicationDidFinishLoading:), but I don't know how or where to set
my controller as a delegate to receive these messages (This is a
Document based application and IB does not show me a "delegate"
outlet when I do the usual control-drag from File's Owner to the
controller)
Any help would be much appreciated.
Thanks,
Rick Bischoff
_______________________________________________
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>) |