FROM : Olivier Scherler
DATE : Tue Apr 19 10:09:57 2005
> I'm sure this is a simple one, but I'm having a bit of trouble
> wrapping my head around how exactly to programatically send messages
> to a custom view in a window.
>
> I wrote a custom view class, imported it into InterfaceBuilder and
> selected it in the "Custom class" popup and got stuck. The class has
> an "addSubviews:(NSArray *) inArray" method which will only be
> updated by a daemon. Since it lives in the nib file, and is loaded
> without any action by me, how do I get a reference so messages can be
> sent to it? Do I need an IBOutlet somewhere? A delegate? An awake
> from nib? Would a Binding be the best route?
In the class that needs the reference to the view (that would be the
controller), you add an IBOutlet:
IBOutlet YourCustomView *theView;
Then in Interface Builder, you control-drag from the controller to the view. THe
inspector appears, displaying COnections -> Outlets and you can select theView
in the outlet list.
You need to have imported the header file of your controller and instanciated it
(via the Classes menu in IB while displaying the Classes tab in the main NIB
window.)
Olivier
∞ Unicode ribbon campaign — No ASCII, anywhere ∞
∞ <http://ithink.ch/unicode> ∞
:: Olivier Scherler :: Neuchâtel (CH) :: <http://ithink.ch/blog/> ::
DATE : Tue Apr 19 10:09:57 2005
> I'm sure this is a simple one, but I'm having a bit of trouble
> wrapping my head around how exactly to programatically send messages
> to a custom view in a window.
>
> I wrote a custom view class, imported it into InterfaceBuilder and
> selected it in the "Custom class" popup and got stuck. The class has
> an "addSubviews:(NSArray *) inArray" method which will only be
> updated by a daemon. Since it lives in the nib file, and is loaded
> without any action by me, how do I get a reference so messages can be
> sent to it? Do I need an IBOutlet somewhere? A delegate? An awake
> from nib? Would a Binding be the best route?
In the class that needs the reference to the view (that would be the
controller), you add an IBOutlet:
IBOutlet YourCustomView *theView;
Then in Interface Builder, you control-drag from the controller to the view. THe
inspector appears, displaying COnections -> Outlets and you can select theView
in the outlet list.
You need to have imported the header file of your controller and instanciated it
(via the Classes menu in IB while displaying the Classes tab in the main NIB
window.)
Olivier
∞ Unicode ribbon campaign — No ASCII, anywhere ∞
∞ <http://ithink.ch/unicode> ∞
:: Olivier Scherler :: Neuchâtel (CH) :: <http://ithink.ch/blog/> ::
| Related mails | Author | Date |
|---|---|---|
| Ken Tozier | Apr 18, 08:34 | |
| Olivier Scherler | Apr 19, 10:09 |






Cocoa mail archive

