Multi window cocoa application

Discussion in 'Mac Programming' started by barbi, Apr 3, 2010.

  1. barbi macrumors newbie

    Apr 3, 2010

    I am currently working on porting an existing open source windows application to mac OSX.
    I am fairly new to cocoa programming.

    The application involves opening a new window for a specifying the parameters of the simulation.
    The second window has about 20 textboxes and cannot be a modal window.
    I have the XIB files and I got the windows working together somehow, but needs a lot of fixing.

    If there are multiple windows in an application, how do I pass values and messages between them?

    What is the best practice in calling a new window and passing values back to the parent window?

    Apple developer library does not have an example source code and many internet sources point to
    /Developer/Examples/InterfaceBuilder/SimpleMultiWindow which is apparently not present in leopard.
    If some one has this example, that would be great. Also, this example being removed hints that there is a new and better way to do it?

    I would appreciate if someone can pass on resources or sample code on working with multiple windows in a cocoa application.
    Just to clarify, this is not a document based application. You can reach me by gmail - barbi dot bruce -

  2. kainjow Moderator emeritus


    Jun 15, 2000
    There are a few ways to do this, it depends on how your app is setup. Generally you have windows (NSWindow) being controlled by window controllers (NSWindowControllers). If both window controllers are sharing data, then you'd probably want another controller that manages that data which both controllers can access. Bindings/KVC would be great here as you could bind your textfields to the controller, which would notify the other window controller through KVO.

    Of course you could do it manually with normal notifications (NSNotificationCenter) or a delegate system. But it depends on your level of knowledge with Cocoa.

Share This Page