Uli's Web Site
[ Zathras.de - Uli's Web Site ]
Other Sites: Stories
Pix
Abi 2000
Stargate: Resurgence
Lost? Site Map!
 
 
     home | blog | moose | programming | articles >> blog

 Blog Topics
 
 Archive
 

15 Most Recent [RSS]

 Less work through Xcode and shell scripts
2011-12-16 @600
 
 iTunesCantComplain released
2011-10-28 @954
 
 Dennis Ritchie deceased
2011-10-13 @359
 
 Thank you, Steve.
2011-10-06 @374
 
 Cocoa Text System everywhere...
2011-03-27 @788
 
 Blog migration
2011-01-29 @520
 
 All you need to know about the Mac keyboard
2010-08-09 @488
 
 Review: Sherlock
2010-07-31 @978
 
 Playing with Objective C on Debian
2010-05-08 @456
 
 Fruit vs. Obst
2010-05-08 @439
 
 Mixed-language ambiguity
2010-04-15 @994
 
 Uli's 12:07 AM Law
2010-04-12 @881
 
 Uli's 1:24 AM Law
2010-04-12 @874
 
 Uli's 6:28 AM Law
2010-04-12 @869
 
 Uli's 3:57 PM Law
2010-04-12 @867
 

More...

What is an Outlet?

I'm just reading Steve Weller's blog about his quest to learn Cocoa, and I remembered how hard it was for me to understand what an IBOutlet and a Connection (like Target/Action) in Interface Builder are. So, I thought in case anyone has the same prior knowledge I had when learning Cocoa, and the same mindset, it might be helpful if I just offered the description of these two as I have them in my head:

Outlet: Is simply a pointer to an object. You add it to your class, and control-drag from the object containing the pointer to the object being pointed to. This is handy, because instead of having to do a call to GetControlByID() to look up an object every time, you can just access it directly, using a pointer that IB will set up for you when loading. This is also why there is the File's Owner: There has to be one already existing object that will receive all those pointers to the newly-created objects, (which you can get by adding the needed outlets to File's Owner).

Target/Action: When I started out, I thought this was something different from an outlet, but actually it's simply a special case. target is an outlet, and action is a method name (or rather, it's a SEL, if that means anything to you at this point). So, what this does is give the NSControl view in question not just an object to send a message to. No, it also gives it the name of the message to send to this object. That way, you can have one controller react to several button clicks with different actions, without needing to switch on the sender parameter.

I hope this helps someone out there. It probably won't be of much use to programming newbies, but people who are already seasoned with C or C++ might benefit.

Reader Comments: (RSS Feed)
No comments yet
Or E-Mail Uli privately.

 
Created: 2005-07-29 @354 Last change: 2005-07-29 @367 | Home | Admin | Edit
© Copyright 2003-2024 by M. Uli Kusterer, all rights reserved.