Re: NULL Outlets in one file work in another
Re: NULL Outlets in one file work in another
- Subject: Re: NULL Outlets in one file work in another
- From: Andy Lee <email@hidden>
- Date: Tue, 26 May 2009 18:53:01 -0400
I don't have time to go into detail, but I think you need to
understand what happens when nibs are loaded and how that's different
from instantiating an object with alloc/init.
On May 26, 2009, at 11:26 AM, Walker Argendeli wrote:
Typos on my part
It's applicationDidFinishLaunching:
That delegate method is in the file App_Delegate.m, which is the
App_Delegate file.
The App_Delegate file is a delegate of the app.
Basically, I have some code working with outlets.
If I put it as a method in App_Delegate, it works. I call it like
this from applicationDidFinishLaunching:
[self doStuff];
If I move the doStuff method to the FirstLaunch.m file and call that
method, again, from applicationDidFinishLaunching, it doesn't work:
FirstLaunch *thing = [[FirstLaunch alloc] init];
[thing doStuff];
Here you've created a brand new instance of FirstLaunch. Its outlets
are not set because this instance was not loaded from the nib.
So in App_Delegate's applicationDidFInishLaunching method, I have
something that looks like this:
[self doStuff];
FirstLaunch *thing = [[FirstLaunch alloc] init];
[thing doStuff];
And either the first line is commented out or the last two are
commented out. The method they are calling is the same, just
located in different files.
If you delete a method from one class and paste into another class it
is not "the same." You really need to understand this. Honestly, I'd
like to explain further but have to run. The key (IIUC) is that
you've created two instances of FirstLaunch and you're not getting why
one has outlets connected and the other doesn't.
--Andy
Both App_Delegate and FirstLaunch have the Outlet ivars connected
in IB and give no warnings or errors.
Thanks for your help,
- Walker Argendeli
On May 26, 2009, at 10:45 AM, Volker in Lists wrote:
Hi,
are you using - (void)applicationDidFinishLaunch:(NSNotification
*)aNotification or - (void)applicationDidFinishLaunching:
(NSNotification *)aNotification ? The first is not a valid delegate
method, the second is. Have you connected your AppDelegate as
delegate of your app - can it receive the notification at all?
And can you clarify on the difference of an App_Delegate file vs.
App_Delegate.m ?
Cheers,
Volker
Am 26.05.2009 um 16:17 schrieb Walker Argendeli:
I have a App_Delegate file. In applicationDidFinishLaunch:, I
instantiate a FirstLaunch object and call its start method. The
weird thing is that this method, which access several IBOutlets,
seems to be working with null outlets. All the connections are
right in IB, and yet the outlets are null. I put the method
inside App_Delegate.m and set the same connections, and the
outlets work fine. I've been staring at the files for an hour,
trying to figure out where I went wrong. The connections are the
same, the headers have the same ivars, and yet in one file, the
outlets work fin, and in another they're null.
Thanks,
- Walker Argendeli
_______________________________________________
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
_______________________________________________
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
_______________________________________________
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