Re: Please help a newbie with delegation!
Re: Please help a newbie with delegation!
- Subject: Re: Please help a newbie with delegation!
- From: Harilaos Skiadas <email@hidden>
- Date: Fri, 25 Feb 2005 12:35:26 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
>The objects are nil, and any message sent to a nil
object is discarded.
>IBOutlets aren't connected at init time; they're
connected when the nib
>is instantiated. If your class implements the method
-awakeFromNib,
>then that method will be called when the
instantiation process is done.
To elaborate a bit more, the order of events, as far
as I understand it, is:
1) The controller is inited.
2) The controller inits the window, using the
information from the NIB file.
3) All objects in the window are inited, and
connections are drawn. (outlets etc)
4) The controller's awakeFromNib method is called.
There are probably other things that I am missing
here, but these are the relevant bits.
So when the controller is inited, it created the two
variables (outlets) textField1 and textField2, but at
that point it has nowhere to connect them to, so they
are set to nil.
Once the window is loaded, the controller sees what
variables it has and connects them to the appropriate
elements of the window. Now, i.e. after step 3, the
outlets in your code are connected to the text fields
that reside in the window.
So in the awakeFromNib method you can do what you
want, having established the necessary links.
Everybody, please correct me if I am wrong.
What I don't understand though, is why you have not
set your controller (i.e. File's Owner) as the
delegate of the text fields in interface builder,
instead of trying to do it programmatically (other
than to learn about awakeFromNib and other wonderful
stuff of course :-) )? Also, is it an application
controller, or just a window controller?
>
>Also, text fields use a different set of delegate
methods than the ones
>you're trying to use; look at the documentation for
NSControl to see
>the methods you should implement.
>
>Nick Zitzmann
><http://www.chronosnet.com/>
>
Haris
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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