Re: [SOLVED] CoreData/NSPersistentDocument initialization
Re: [SOLVED] CoreData/NSPersistentDocument initialization
- Subject: Re: [SOLVED] CoreData/NSPersistentDocument initialization
- From: Jerry Krinock <email@hidden>
- Date: Fri, 20 Nov 2009 23:07:18 -0800
On 2009 Nov 20, at 12:04, Oftenwrong Soong wrote:
> However, initWithType:error is never called for new document creation (or any document creation for that matter). I placed a breakpoint inside the method and execution does not pause there. Instead, -(id)init gets called.
It's not 'instead'. It's both. When a new document is created, Cocoa invokes -initWithType:error:. When you override this method, you must invoke super. -[NSPersistentDocument initWithType:error:] will then invoke -init. Likewise if you override -init, invoke super.
> This is a problem because -(id)init is called when documents are opened as well as created from scratch.
Actually it's rather handy for doing *some* initializations which you want done in both new and old documents. I say *some* because your persistence stack is not yet functioning at this point.
_______________________________________________
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