Re: Interface Builder & Wiring Objects
Re: Interface Builder & Wiring Objects
- Subject: Re: Interface Builder & Wiring Objects
- From: Greg Deward <email@hidden>
- Date: Mon, 17 Nov 2008 14:36:07 -0500
Luke / Randall,
Thanks for replying. I did not want to embarrass Mr. Hillegass with
my ignorance, but his book IS the one I am trying to follow. I am
currently working on his "To Do List" example in Chapter 6 (page 110).
In my example, I have the following items in my App Controller class:
Text Field (along with an IBOutlet)
Button (along with an IBOutlet)
Table View (along with an IBOutlet)
Mutable Array instance variable
My concern is whether or not the DIRECTION in which I CTRL-drag the
objects. For example, if do I drag from the Button object to the App
Controller or do I CTRL-drag from the App Controller to the Button?
I'm coming from a C# / .NET environment. While there ARE visual
design tools involved, it is much more manual. For example, adding a
Button to a Form creates the implmentation in the source file. Double-
clicking the control then creates the event handler for the object.
Anything that you may want to do is handled programatically.
Basically, since I cannot see what is happening under the hood, I'm
beginning to second-guess that the calls will be made in the right
direction.
I hope that made sense. Again, my apologies for such a noob-ish
question.
Thanx,
Fred
On Nov 17, 2008, at 1:56 PM, Randall Meadows wrote:
On Nov 17, 2008, at 11:09 AM, Greg Deward wrote:
Good afternoon!
I am trying to learn Cocoa and am having difficulty remembering
which direction to CTRL-drag controls to wire up the controls in
Interface Builder. For example, dragging from my button to my App
Controller (NSObject) or vice versa. Does anyone have a way to
explain this that might make it stick?
Aaron Hillegass, in his "Cocoa Programming for Mac OS X" book
explains it this way:
"Now you are going to introduce some objects to each other....To
introduce one object to another, you will control-drag from the
object that needs to know to the object it needs to know about."
So, for instance, a class needs to know about its NSButton outlet,
so you control-drag from the class to the NSButton in the window (to
set the IBOutlet). The NSButton needs to know what method to call
when it is pressed, so you control-drag from the button to the class
(to set the IBAction).
Or do what Luke said in his response... :)
It seems to me that a button should make a call to my App
Controller when the click event is fired; therefore I should CTRL-
drag FROM the button TO the NSObject. This would allow me to select
the appropriate Received Action (ie, "doSomething", etc.").
Yep, sounds like you have the basic gist of it...
However, if I need to do something with a text box (read from it)
and a table view (insert an item), I should go the other way...
since I'm going to fetch from the text field and then insert into
the NSArray that is feeding the text view.
But, what triggers the action of reading from the text field and
inserting that into the array that feeds the table (you said text,
but I assume that's a typo) view? A button gets pressed? The user
presses Enter? You set the action of the object that does that
action just as you would otherwise.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden