• 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
NSDocument new file logic
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDocument new file logic


  • Subject: NSDocument new file logic
  • From: Martin Hewitson <email@hidden>
  • Date: Wed, 29 Jun 2011 08:58:01 +0200

Dear list,

I have an NSPersistentDocument subclass which encapsulates a project for the user. When the user creates a new project, they specify a name and a location on disk. I then want to create a new instance of my NSDocument subclass as if it was saved exactly where the user wants it to be. I want to do this because the app then creates additional files (which are managed by the project -- think Xcode) which are placed in the same location as the project file.

In the past I achieved this in a somewhat unsatisfactory way by just calling newDocument: then saveDocument: and getting the user to immediately save the document before the app does the rest of the setup steps. This was working, but it does mean that the user is immediately presented with a save panel, which is not so nice. I'd rather present a custom panel telling them to enter a project name and a location on disk. Anyway, that aside, this scheme doesn't seem robust to future OS implementations (maybe the saveDocument: behaviour changes, for example).  What I'd really like is an NSDocumentController method like

-(id)createDocumentAtURL:(NSURL*)aURL ofType:(NSString*)type error:(NSError**)anError;

but that doesn't seem to exist.

Can anyone recommend a way to do what I want? In other words, to programmatically create an NSDocument instance already saved on disk? This behaviour is essentially what Xcode is doing when one creates a new project.

Best wishes,

Martin

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
    Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





_______________________________________________

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

  • Follow-Ups:
    • Re: NSDocument new file logic
      • From: Quincey Morris <email@hidden>
  • Prev by Date: problem with applying md5 to data
  • Next by Date: Re: problem with applying md5 to data
  • Previous by thread: Re: problem with applying md5 to data
  • Next by thread: Re: NSDocument new file logic
  • Index(es):
    • Date
    • Thread