• 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
subclasses of NSPersistentDocument and NSManagedObjectContext, and undo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

subclasses of NSPersistentDocument and NSManagedObjectContext, and undo


  • Subject: subclasses of NSPersistentDocument and NSManagedObjectContext, and undo
  • From: Don Briggs <email@hidden>
  • Date: Wed, 25 May 2005 14:00:52 -0500

Hello, all —

I, too, need a subclass of NSPersistentDocument to use a subclass of NSManagedObjectContext.
I followed mmalc's code below, and it works for me -- with just one glitch.


The documents act, save and open as expected.
I can add and remove contained objects, and edit them.
The undo commands work fine.

But, but ... the documents just never get dirty, no matter what I do to the contained objects.
(The contained objects are instances of subclasses of NSManagedObject.)
I rather expected that NSManagedObjectContext and NSPersistentDocument would just "do the right thing" without further guidance from me.


What did I neglect or botch? Any guesses?

Don

On May 22, 2005, at 9:13 PM, Todd Blanchard wrote:


I've been digging, literally for about 6 hours trying to get a clear understanding of NSPersistentDocument's initialization process.
I have a subclass of NSManagedContext that I want my subclass of NSPersistentDocument to use.
Where is the good place to arrange for the NSPersistentDocument to get my subclass?
I suppose I could use posing, but I'd prefer something more straightforward.



Per the documentation:

"You can customize the architecture of the persistence stack by overriding the methods managedObjectModel and configurePersistentStoreCoordinator:forURL:ofType:error:."


- (NSManagedObjectContext *)managedObjectContext
{
if (myManagedObjectContext == nil) {
myManagedObjectContext = [[MyManagedObjectContext alloc] init];


NSPersistentStoreCoordinator *psc =
[[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
[myManagedObjectContext setPersistentStoreCoordinator:psc];
}
return myManagedObjectContext;
}


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: subclasses of NSPersistentDocument and NSManagedObjectContext, and undo
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Build Style Problem
  • Next by Date: Re: Build Style Problem
  • Previous by thread: Re: Build Style Problem
  • Next by thread: Re: subclasses of NSPersistentDocument and NSManagedObjectContext, and undo
  • Index(es):
    • Date
    • Thread