Re: NSUndoManager f@*#ing up Core Data database
Re: NSUndoManager f@*#ing up Core Data database
- Subject: Re: NSUndoManager f@*#ing up Core Data database
- From: Ron Lue-Sang <email@hidden>
- Date: Wed, 8 Oct 2008 09:23:47 -0700
On Oct 8, 2008, at 4:17 AM, Ruotger Skupin wrote:
Hi,
I have a core data database with two contexts attached to it. One
read-only for the main thread and bindings, one read/write for a
background thread that takes data from the network and feeds it into
the database. I know this is an effed-up design you shouldn't copy,
but it won't change.
(For why this is a bad idea: http://lists.apple.com/archives/Cocoa-dev/2007/May/msg00066.html
but please let's not discuss this here, thx)
Where shall we discuss this then? I have comments =)
The background thread (called database access thread) is the one
that changes the database exclusively, all database modifying is
funnelled through it. The main thread is supposed to only read-
access the database. How do I do that? Since I already use
mogenerator (http://rentzsch.com/code/mogenerator) I changed the
generator template to check for the correct thread on write access.
That way I could pinpoint a lot of accidental write accesses, which
led to context inconsistencies.
There's one I could not get rid of. It is done by the NSUndoManager.
Which is weird as there is no write access to the database from the
main thread the NSUndoManager is so keen on undoing. What is going on?
In my case I'd like to get rid of the NSUndoManager altogether as I
don't need it. Is there a way to do that?
Well, the short answer is:
backgroundManagedObjectContext = [[NSManagedObjectContext alloc] init];
[backgroundManagedObjectContext setUndoManager:nil];
But that's assuming that the undoManager in frame 15 of your bt is
[backgroundManagedObjectContext undoManager]. I think that's the only
way you'd get into the situation you've described.
--------------------------
RONZILLA
_______________________________________________
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