I believe you might be looking for:

- (id)initWithType:(NSString *)typeName error:(NSError **)outError

which you can implement in your NSPersistentDocument subclass. I've done it 
this way before; I also did the following steps to give the user a new document 
that has no changes:

1) disable undo on the managed object context

                NSManagedObjectContext *managedObjectContext = [self 
managedObjectContext];
                [[managedObjectContext undoManager] disableUndoRegistration];

2) do changes to the core data model

3) re-enable undo on the moc

                [managedObjectContext processPendingChanges];
                [[managedObjectContext undoManager] enableUndoRegistration];


One problem that arises here is to handle the fact that the new document has 
not been saved so far, so if you need access to the filepath for the new 
document, you need to get the user to save the new document straight away, and 
bail out if they decline.

Cheers,

Martin


On May 23, 2010, at 1:24 PM, Bryan Zarnett wrote:

> I have a Document-based core data application ( from template). I would like 
> to determine in "MyDocument" if the file is new -- has no content so that I 
> can populate a few of the models with required default data.
> 
> I was wondering what is the base way to approach this? I didn't see any 
> particular API like IsNewDocument() which would have been handy!
> 
> Thoughts?
> 
> Bryan
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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/martin.hewitson%40aei.mpg.de
> 
> This email sent to [email protected]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 protected]
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to