• 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
CoreData/NSPersistentDocument initialization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreData/NSPersistentDocument initialization


  • Subject: CoreData/NSPersistentDocument initialization
  • From: Oftenwrong Soong <email@hidden>
  • Date: Fri, 20 Nov 2009 12:04:06 -0800 (PST)

Hi all,

My document model is Core Data based. When a new document is created, I must initialize the model to contain several objects with default values.

I followed Apple's "Departments" example:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/NSPersistentDocumentTutorial/04_Department/department.html#//apple_ref/doc/uid/TP40002832-SW1

At that page, it explains how to create a new Department object when a new document is created. It does so by implementing -(id)initWithType:error: in the MyDocument class, which is a NSPersistentDocument subclass, just like my own app's document class.

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. This is a problem because -(id)init is called when documents are opened as well as created from scratch.

My questions are:
1. Have I overlooked something?
2. Is there a better way to initialize new Core Data models to a known state? (Yes, I know I can create a whole model in code, a la the Core Data Utility example, but I mean when using NSPersistentDocument.)

Thanks,
Soong




_______________________________________________

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: [SOLVED] CoreData/NSPersistentDocument initialization
      • From: Oftenwrong Soong <email@hidden>
  • Prev by Date: Re: IBOutlets or property + binding
  • Next by Date: Re: question about informal protocols
  • Previous by thread: Re: question about informal protocols
  • Next by thread: Re: [SOLVED] CoreData/NSPersistentDocument initialization
  • Index(es):
    • Date
    • Thread