Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mrTuborg

macrumors newbie
Original poster
Nov 9, 2009
2
0
Hello

I'm a newbie in a cocoa development. I'm trying to write my first application.
My application window have one Button, one NSComboBox and one NSTextField.

I define action to my controller class from button.
Also defines outlets from controller class to NSComboBox and NSTextField.

But.... I don't understand - how write initial values to combo and textfield when my application startups? I wrote method 'init'. But it isn't helps to me.

At this moment I have following behavior of my app:

1. Init of controller class (there I'm trying to initialize outlets fields)
2. applicationDidFinishLaunching from ...AppDelegate.m
3. EventLoop of my Application.

I need some tips to resolving my problem....
 
Hello

I'm a newbie in a cocoa development. I'm trying to write my first application.
My application window have one Button, one NSComboBox and one NSTextField.

I define action to my controller class from button.
Also defines outlets from controller class to NSComboBox and NSTextField.

But.... I don't understand - how write initial values to combo and textfield when my application startups? I wrote method 'init'. But it isn't helps to me.

At this moment I have following behavior of my app:

1. Init of controller class (there I'm trying to initialize outlets fields)
2. applicationDidFinishLaunching from ...AppDelegate.m
3. EventLoop of my Application.

I need some tips to resolving my problem....

[myClass initialize] is called for each _class_ that you use. At that point there are no objects of that class yet. There you can set up some static variables for example.

[xxx awakeFromNib] is called for each object in a nib file immediately after the nib file is loaded. In awakeFromNib, you should do all the things that you would have liked to do in Interface Builder but for some reason couldn't. This _may_ be the right place.

[mydelegate appliationDidFinishLaunching] is called - guess what - when the application has finished launching. That is where you can set up things, read the preferences and do things accordingly, and so on.
 
[myClass initialize] is called for each _class_ that you use. At that point there are no objects of that class yet. There you can set up some static variables for example.

[xxx awakeFromNib] is called for each object in a nib file immediately after the nib file is loaded. In awakeFromNib, you should do all the things that you would have liked to do in Interface Builder but for some reason couldn't. This _may_ be the right place.

[mydelegate appliationDidFinishLaunching] is called - guess what - when the application has finished launching. That is where you can set up things, read the preferences and do things accordingly, and so on.

BIG THANKS! awakeFromNib saves me :D
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.