Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How to manually change NSDocumentController in Doc-based App

How to manually change NSDocumentController in Doc-based App
Thread Tools
Apocalypse
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Dec 14, 2001, 01:51 PM
 
Hello,

In a document-based application I am writing I need to change the open panel and save panel to have an additional view for document type similar to what AppleWorks does. I am trying to find the best place to do this but I am unsure. Based on some documentation I have read, it looks like I will have to sub-class NSDocumentController and work from there. I know how to do everything once I get that far but I don't know where to make this sub-class. Would it be in the MainMenu.nib? No-matter where it is, I don't know how to ensure that the App will use my instance instead of an instance of the parent (default) NSDocumentController.

My guess is to make it in the MainMenu.nib and make my instance the delegate of NSApp but I am not confident in it. I will play around with that idea but if someone knows for certain can you please help me out.

Thanks,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
lindberg
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
Dec 14, 2001, 02:07 PM
 
The first instance of an NSDocumentController (or a custom subclass) to be allocated will become the +sharedDocumentController, which is what you want. The easiest way is just to instantiate it in the main nib, like you say. It doesn't need to be the app delegate, though there's nothing wrong with doing that (you're basically combining the main app controller with the document controller, which if there's not much code to deal with can make sense).

Afterwards, you can use [NSDocumentController sharedDocumentController] to get access to your instance. Look at the comment in the NSDocumentController.h for that method for more info.

BTW, to set up the accessory view for Save panels, you'll have to do that in your NSDocument subclass(es).
     
smeger
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Dec 17, 2001, 12:08 PM
 
You can subclass NSDocumentController in MainMenu.nib, instantiate it, and then connect File Owner's delegate to your instantiated subclass.

I think you can also change the class of File Owner to your subclass, but Interface Builder gave me a warning when I tried it.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:48 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,