• 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: how to instantiate MyDocument with file from open panel?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to instantiate MyDocument with file from open panel?


  • Subject: Re: how to instantiate MyDocument with file from open panel?
  • From: Jacob Lukas <email@hidden>
  • Date: Fri, 7 Dec 2007 09:41:23 -0500


On Dec 7, 2007, at 08:46, Jens Miltner wrote:


On 06.12.2007, at 20:59, Nathaniel Gottlieb-Graham wrote:

I've run an open panel and called the openPanelDidEnd: selector, and I have the file the user has chosen in an array. Now I'm a little stuck because I want to do something with that file; I want a new MyDocument instance to be created and load the data from the file into a QTMovieView I've set up in IB. I'm unsure how to do this, in particular instantiating MyDocument. Googling for it indicates very few hits, so I'm probably approaching the problem the wrong way.
Thanks for the help, all.

you'll need to specify the file-type -> class mapping in the Info.plist.
The easiest way is to go to your application target's "Properties" pane and define a new Document Type there. Once you've associated the document type with your MyDocument class, AppKit will instantiate your class when an appropriate document is opened.

Then, implement -readFromData:ofType:error:, - readFromFileWrapper:ofType:error:, or -readFromURL:ofType:error: to initialize your document from the opened file. Finally, connect the button on your Welcome screen to First Responder's openDocument:. The document architecture should take care of the rest for you.


-Jacob
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >how to instantiate MyDocument with file from open panel? (From: Nathaniel Gottlieb-Graham <email@hidden>)
 >Re: how to instantiate MyDocument with file from open panel? (From: Jens Miltner <email@hidden>)

  • Prev by Date: Re: -[NSImage TIFFRepresentation] failing on the multiple files icon?
  • Next by Date: trouble keeping NSTableView sorted
  • Previous by thread: Re: how to instantiate MyDocument with file from open panel?
  • Next by thread: -[NSImage TIFFRepresentation] failing on the multiple files icon?
  • Index(es):
    • Date
    • Thread