Q:  I am using the function NXGetNamedObject(const char * aname, id owner) to find the id of my NXBrowser object.  My main program containing the loadNibSection:owner: was created by InterfaceBuilder and had NXApp in the owner: argument.  However, passing NXApp as the owner always returns a nil id. What am I doing wrong?

A:  By default, InterfaceBuilder assigns the Application object (NXApp) as the owner of a Window, and a View's Window as the owner of that View.  Since NXBrowser is a subclass of View, you must use the NXBrowser's Window id  instead of NXApp as owner in the function NXGetNamedObject().

Below is a code snippet for illustration:

id myWindow, myBrowser;

/* Get the id for the browser's window */
myWindow = NXGetNamedObject("MyWindow", NXApp);
/* Get the id of the browser itself */
myBrowser = NXGetNamedObject("MyBrowser", myWindow);



Note that named objects are a big performance loser because of the memory it takes to keep track of all the names of the objects. For this reason, we would recommend that you use loadNibSection:owner:withNames:NO when loading in nib files.  Try to use outlets instead of named objects whenever possible.

QA816

Valid for 2.0, 3.0