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

hvolmer

macrumors newbie
Original poster
Jul 7, 2011
1
0
Hello.

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.

Thanks
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.