PDA

View Full Version : How to initialize window of my application?




mrTuborg
Nov 9, 2009, 03:34 AM
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....



gnasher729
Nov 9, 2009, 06:30 AM
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.

mrTuborg
Nov 9, 2009, 11:49 AM
[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