• 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: Newbie Q : getting rid of MyDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie Q : getting rid of MyDocument


  • Subject: Re: Newbie Q : getting rid of MyDocument
  • From: Sean Murphy <email@hidden>
  • Date: Tue, 13 Jun 2006 16:47:20 -0400


On Jun 13, 2006, at 4:00 AM, email@hidden wrote:

 So I created fresh new files YourDocument.h,.m,&.nib (YourDocument is
a subclass of NSDocument) in the new
project, and copied all the code, view data and connections. The
new project builds without problem, but I don't know what to do next :
where and how do I tell the application to launch YourDocument.nib
when the application is opened ?

Hey Ewan,

You must edit your application's Info.plist, and register your NSDocument subclass as the class for a particular document type. Choose Project>Edit Active Target, and under the "Properties" tab, add an entry for your document and make sure you set "Class" to contain your custom NSDocument subclass.

The whole document-based app thing was confusing me as well, because it seemed almost like voodoo that the NSDocument subclass was instantiated at launch time. Nowhere was a delegate set for NSApplication, and no object in MainMenu.nib was responsible for creating the new document.

The document-type registered in the Info.plist seems to prompt the use of document-based objects, such as NSDocumentController, etc. This is how you can the application to launch MyDocument.nib. From the ADC:

"However, if your application subclasses NSDocument to handle a specific document type, you should specify the document subclass name as the Sketch application (which is available in /Developer/Examples/ AppKit/Sketch) does with SKTDrawDocument ."
<http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/ Concepts/DocTypePList.html#//apple_ref/doc/uid/20000024>


To read up some more about how the NSDocument architecture works, see the following documentation pages:

Actual Implementation of a Doc-Based app:
<http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/ Tasks/ImplementingDocApp.html#//apple_ref/doc/uid/20000029>


Entire overview of Doc-based:
<http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/ index.html>


Hopefully that helps.
-Murph
_______________________________________________
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


References: 
 >Newbie Q : getting rid of MyDocument (From: email@hidden)

  • Prev by Date: Re: Freeze Dried Objects/Archiving
  • Next by Date: Problems with NSURLRequest and HTTP POST Form Data
  • Previous by thread: Newbie Q : getting rid of MyDocument
  • Next by thread: create a file appending data
  • Index(es):
    • Date
    • Thread