Question

I need to create several windows before NSDocument is loaded, or create a window that blocks NSDocument window and top menu.

I tried several solutions - but they didn't work right.

  1. modal window, one after another. there were some problems with Async URLConnection, and some other problems with my NSDocument content.

  2. I created custom MainMenu.xib with no menu, that opens my preinitialize windows. here i found some other problems, when a file(associated with my application) is opened - the Document Window initializes. Here i tried to subclass NSDocumentController, but i found no way to pause the "open document". (i want the document to be opened anyway, but only after the preinitalize windows would be closed).

So what is the right way to do this?

Was it helpful?

Solution 2

So the right answer is to implement:
* application:openFiles:
* applicationShouldOpenUntitledFile:

and implement your own document creation. this is the way it worked for me.

MyDocument* document = [[MyDocument alloc] 
                             initWithContentsOfURL:fileURL 
                                            ofType:[fileName pathExtension] 
                                             error:nil
                       ];
  if(document)
  {
     [[NSDocumentController sharedDocumentController] addDocument:document];
     [document makeWindowControllers];
     [document showWindows];
 }

of course you need to write error handling code.

OTHER TIPS

Implement applicationShouldOpenUntitledFile: in your app delegate to return NO if the user has to go through the not-registered-yet dialog first.

In the action methods for your “Trial” and “Confirm Registration” buttons, create the untitled document yourself (by sending the necessary message to the document controller).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top