Re: variable problem is driving me nuts
Re: variable problem is driving me nuts
- Subject: Re: variable problem is driving me nuts
- From: Jens Alfke <email@hidden>
- Date: Sat, 27 Oct 2012 18:02:04 -0700
On Oct 27, 2012, at 4:51 PM, H Miersch <email@hidden> wrote:
> in the app delegate itself, there's this line, in applicationDidFinishLaunching:
>
> clients = [[NSMutableArray alloc] init];
>
> that works as expected. so far so good. but later, in another method in the app delegate, there's this line:
>
> int count = [clients count];
Set a breakpoint on both the lines you quoted above, and see which one gets hit first. -applicationDidFinishLaunching: is not necessarily the first method invoked on the application delegate; it gets instantiated when the nib loads, and there can be activity during nib loading that ends up calling methods in the delegate.
In general, initialization code like this in a nib-loaded object should go into its -awakeFromNib method, which is [almost] guaranteed to be the first method invoked on that object.
—Jens
_______________________________________________
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