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: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to