The NSDocumentController
class keeps track of the first instance of NSDocumentController
(or a custom subclass) that is created and returns that instance from its sharedDocumentController
class method. To get your application to use your custom subclass of NSDocumentController
, you must ensure your subclass is the first instance of NSDocumentController
created when the application starts up. There are two ways to do this:
Create your subclass in the main nib file.
The main nib file is loaded by the application when it starts up. If you create an instance of your subclass in the main nib file, the application loads it when it launches and uses it as the shared document controller. If the default NSDocumentController
object was configured as your application delegate, then be sure to connect the application’s delegate outlet to the instance of your subclass.
Create an instance of your subclass in the applicationWillFinishLaunching:
method.
The application does not ask for its shared document controller until after the applicationWillFinishLaunching:
message is sent to its delegate. Therefore, you can create an instance of your subclass of NSDocumentController
in your application delegate’s applicationWillFinishLaunching:
method and that instance will be set as the shared document controller.
Last updated: 2010-03-24