PDA

View Full Version : Connecting NSDocument xib objects to app controller




HiRez
Sep 26, 2008, 03:29 AM
Hi, I've got a document-based Cocoa app with an app controller object. I've instantiated that in the MainMenu xib and made it the NSApp delegate. So far, so good. The problem is, I want objects in my NSDocument's xib file to connect to the app controller object. I can drag another custom object out in the document's xib and make it the app controller class, but that's going to give me one controller per document, right? Not what I want, it's a singleton app controller.

Now I can make it work by making an "appCon" instance variable in the NSDocument class and setting that programmatically with appCon = [NSApp delegate];. But, this just seems kind of sloppy to me, routing those calls through the NSDocument class. That fine if that's the way it is, just wondering if there's some cleaner way to go about it that I'm missing, where I can connect to an app controller object directly in the document's xib file.