Issues adding IB elements to simple program

Discussion in 'Mac Programming' started by hvolmer, Jul 7, 2011.

  1. hvolmer macrumors newbie

    Jul 7, 2011

    I have an existing "gui-free" application that I'm trying to add a couple of menu controls to. The problem: The application currently consists of three classes: the "Main app" class (that XCode creates) - this generates the next class; a second class that runs a small server; and a third singleton class created by the server to act as a data source.

    What I tried: Adding IBOutlets for the IB gui objects directly to each class. In IB I connected the IB gui objects to these custom objects.

    What happens: IB apparently spawns up it's own set of these objects, rather than talking to the ones that are created by the existing code. So GUI interactions don't talk to the appropriate instances of these objects.

    How should I be connecting IB objects to my existing stuff? Should I connect all the IB objects to the Main app class and drill through the server and data source classes to update the gui? I didn't plan on this addition when I created the classes.

  2. kainjow Moderator emeritus


    Jun 15, 2000
    If you are adding class objects into your nib, those get instantiated as separate objects from what you do in code.

    Generally the way things are handled is you have the MainMenu nib which has a single object in it - the app delegate (and often the main window controller). The nib will create that object for you, and the nib itself gets loaded by the NSApplicationMain function.

    It might be easier to create a new application project and merge in your existing code into that piece by piece.

Share This Page