Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSPersistentDocument new Untitled Document

NSPersistentDocument new Untitled Document
Thread Tools
11011001
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Jun 2, 2005, 08:09 PM
 
I would like to be able to initialize an NSPersistentDocument only when a new Untitled Document is created. In other words I would like to populate it's model with a few objects, but I don't want a newly opened document to be repopulated with these items. Does anyone have some ideas how I could go about doing this, preferably within the NSPersistentDocument subclass.

I have tried checking the managedObjectContext within init to see if those items are already there, but unfortunately it seems that the managedObjectContext hasn't been filled at this point.
     
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Jun 5, 2005, 08:32 PM
 
NSPersistentDocument uses a specific method to do exactly this. It's an initialiser that is only called for new documents, and not for opening existing documents. See the CoreData NSPersistentDocument tutorial on Apples developer documentation pages for the details:

http://developer.apple.com/documenta...umentTutorial/
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:13 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,