Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!uc!cs.umn.edu!pico!wisdom From: wisdom@pico.cs.umn.edu (Scott Wisdom) Newsgroups: comp.sys.next Subject: Re: Outlet to 'global' interface object. Keywords: outlet,object,interface Message-ID: <1990Oct22.044434.2933@cs.umn.edu> Date: 22 Oct 90 04:44:34 GMT References: <406@nwnexus.WA.COM> Sender: news@cs.umn.edu (News administrator) Organization: University of Minnesota, Minneapolis - CSCI Dept. Lines: 72 Nntp-Posting-Host: pico.cs.umn.edu >I have several nibs, each with a file owner object. I would like each file >owner object to contain an outlet to a single object contained in yet >another nib. However, Interface builder does not seem to allow me >to connect an outlet of an object in one nib to an object in another >nib. The only solution I can think of is to forget Interface Builder >and simply use a global id variable to represent the outlet object. >But I would much prefer to have Interface Builder support such a design. >Does anyone have any suggestions how it might? There are several ways of doing this. I'll describe the easier way here. In Interface Builder, while your in your application nib, go to the Classes Panel and subclass Application. Select the 'Files Owner' in your Objects Panel, then bring up the Attributes Inspector (command-1). Change the objects class from Application to your new application subclass. Now, with the new 'Files Owner' selected, go into the Class Inspector (command-5) and create an outlet. Now connect this outlet to your global object, so the application object will know about it. Unparse the new application class via the Classes panel. Now edit the resulting .h & .m files and add a new method so the files look something like this: myAppSubclass.h: ----------------------------------------------------- @interface myAppSubclass:Application { id theOutlet; } - setTheOutlet:anObject; - getGlobalObject; //the new method ------------------------------------------------------ myAppSubclass.m: ------------------------------------------------------ @implementation myAppSubclass - setTheOutlet:anObject { theOutlet = anObject; return self; } - getGloablObject //the new method { return theOutlet; } ------------------------------------------------------- Now, when you create your objects in other nib modules, just add #import "myAppSubclass.h" at the beginning of the file and you can get the global object any time by sending NXApp a getGlobalObject message: [[NXApp getGlobalObject] performTheGlobalObjectsMethod]; Of course, this isn't the only way to do it, but probably the easiest. It's much more object oriented than using (ugh) actual global variables. This can also be extended to allow a 'global' object to reside outside the sphere of the main 'application' nib and in another nib altogether. I've been forced to do this, but it's a bit more complicated. I'll sumerize that procedure if there's interest. - Scott Wisdom Coda Music Software Hacker wisdom@heckle.cs.umn.edu <<-- Send e-mail here