Re: Interface Builder Outlets
Re: Interface Builder Outlets
- Subject: Re: Interface Builder Outlets
- From: John Pannell <email@hidden>
- Date: Thu, 15 Dec 2005 15:19:09 -0700
Hi Johnathan-
The short answer is no. In code, you let your objects know in their
ivars that you are going to be using IB to connect them. So if you
had an object (an instance of MyObject, lets say) that needed to know
about one of its views (an instance of MyView), then in your header
you would have...
@interface MyObject : NSObject {
IBOutlet MyView *superCoolView;
}
The "IBOutlet" keyword lets the compiler(?) know that the connection
is being established in IB.
Any object (a window, a view, a button) you drag/drop into IB is
already alloc'ed and init'ed. I don't really think of outlets as
being objects, per se, but rather a substitute for alloc/init. If
you didn't use IB to drag and drop and hook things up, you'd need to
do something like this in your code...
superCoolView = [[MyView alloc] initWithFrame:NSMakeFrame(20, 20,
100, 100)];
IB saved you the line of code, plus gave you the ability to visually
see the frame of the view, rather than specify it numerically.
Hope this helps!
John
On Dec 15, 2005, at 3:03 PM, Jonathan Faulkenberry wrote:
Hi all. This is a very newbie question concerning basic Cocoa
concepts. When I create an outlet in Interface Builder, is it
necessary to alloc and init it?
Jonathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40positivespinmedia.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden