• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: multiple documents in an app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multiple documents in an app


  • Subject: Re: multiple documents in an app
  • From: Boyd Collier <email@hidden>
  • Date: Sat, 5 Nov 2005 15:08:05 -0800

Thanks very much for replying to my question.

After posting the question and before reading your reply, I had done most of what you suggested. I also have read the documentation several times but am still confused. Here is what I tried most recently, to no avail.

This is the problem that I originally posted:
I'm attempting to create a simple but user-friendly app to do some heavy-duty number crunching at the same time as learning my way around Cocoa. Thus far, I've created an document-based app that opens and displays the contents of a text file containing data to be analyzed and have succeeded in extracting all the info I need to carry out the analysis. The document is displayed in a window with a single button, which, when pressed, takes me into a controller via an IBAction, which is where the heavy-lifting gets done. When this is completed, I want to display the results in a separate window that shows only output from the analysis and doesn't have any buttons, etc. but which can be saved in the usual manner.

Here is where things now stand: In the method invoked when the user hits the one button in the window showing data to be processed, I tried programmatically creating a window and a controller, as follows:


NSDocument *myOutputDocument = [[NSDocument alloc] init];
NSWindowController *outWindowController;
outWindowController = [outWindowController initWithWindowNibName:@"outputWindow"];


A nib file named outputWindow was of course added to my project, but in the above attempt to use initWithWindowNibName to initialize outWindowController, the window controller is nil. I've also tried to initialize the window controller using a programmatically created window and initWithWindow, but that doesn't work either.

Undoubtedly, I'm overlooking something very simple, but I can't seem to put my finger on it. Any help from anyone would be GREATLY appreciated!

Boyd


On Nov 3, 2005, at 12:53 PM, mmalcolm crawford wrote:


On Nov 3, 2005, at 12:03 PM, Boyd Collier wrote:


I presume that what I have to do is create another nib file with a window of the sort that I want for showing the output, and I know how to do this. But what I'm not clear on is how to add this to the array of documents maintained by NSDocumentController. Do I put a controller of some sort into this new nib? If so, should it be a subclass of NSDocument or of NSWindow or of NSObject?


See <http://developer.apple.com/documentation/Cocoa/Conceptual/ Documents/Concepts/OverviewDocArchitecture.html>
<http://developer.apple.com/documentation/Cocoa/Conceptual/ Documents/Concepts/RolesOfDocObjects.html>
and
<http://developer.apple.com/documentation/Cocoa/Conceptual/ Documents/Tasks/FAQ.html#//apple_ref/doc/uid/20000954-1081912>


In brief:

Create a new subclass of NSDocument and nib file.
Set an instance of the subclass of NSDocument as the File's Owner of the nib.
Implement - (NSString *)windowNibName to return the name of the new nib.
Update your properties list as appropriate (see reference above).


Implement a subclass of NSDocumentController to handle different document types (or, if you already have an app controller or delegate, implement suitable methods in that).

mmalc

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40sunstroke.sdsu.edu


This email sent to email@hidden



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: multiple documents in an app
      • From: Cameron Hayne <email@hidden>
    • Re: multiple documents in an app
      • From: mmalcolm crawford <email@hidden>
References: 
 >multiple documents in an app (From: Boyd Collier <email@hidden>)
 >Re: multiple documents in an app (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: RunLoops
  • Next by Date: Re: obj-c on linux and Cocoa on linux, where can reach them ?
  • Previous by thread: Re: multiple documents in an app
  • Next by thread: Re: multiple documents in an app
  • Index(es):
    • Date
    • Thread