Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help] How to get instance of instantiated Controller in nib from Controller in another nib? (Java)



Mark brought up some of the stickier parts of accessing classes in another bundle. The principal class can be set in Project Builder under the bundle settings. The problem with this though, is that there can only be one principle class per stand-alone bundle, not .nibs; sorry for the confusion.
Mark, what you are trying to do is somewhat a no-no. When you loaded the secondary bundle, you had to specify the bundle's owner and that class is your link to everything in that bundle. According to the precepts of OOP programming, the NSPanel shouldn't know or care about your MyMainController class.
Tyler and Mark, in IB, select the File's Owner proxy icon. Open the Inspector and change the class to whatever class you will be proffering to be the File's Owner (it's default is NSObject in ObjC). Then, you can start adding outlets and actions, etc. to the File's Owner's class and connect these as though you would a regular class. When the .nib is loaded, NSBundle will automatically connect all the outlets and actions for you. Therefore, in your example Mark, you would connect the action to the File's Owner and since the file's owner must exist before the secondary bundle is loaded, it must be contained in the primary one or be created by a class in the primary .nib and therefore can pass along the action to whichever one of the higher-level objects it wishes.
It took me forever to figure this out too. I think the formal explanation is on page 87 or so in "Tools & Techniques". Hope I helped,

Brendan Younger


References: 
 >RE: [Help] How to get instance of instantiated Controller in nib from Controller in another nib? (Java) (From: "Mark Orchard" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.