How to initialize window of my application?

Discussion in 'Mac Programming' started by mrTuborg, Nov 9, 2009.

  1. mrTuborg macrumors newbie

    Nov 9, 2009

    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....
  2. gnasher729 macrumors P6


    Nov 25, 2005
    [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.
  3. mrTuborg thread starter macrumors newbie

    Nov 9, 2009
    BIG THANKS! awakeFromNib saves me :D

Share This Page