Re: NSManagedObjectContext won't save...
Re: NSManagedObjectContext won't save...
- Subject: Re: NSManagedObjectContext won't save...
- From: Matthew Firlik <email@hidden>
- Date: Tue, 21 Feb 2006 22:39:35 -0800
On Feb 21, 2006, at 5:56 AM, Jean Le Clerc wrote:
I have this very strange problem where a ManagedObjectContext won't
save... Here's a brief explanation of the setup:
NSManagedObject
-> SBManagedObject
-> SBAccountableObject (Abstract)
-> SBEntityObject (Abstract)
-> SBDataSource
SBEntityObject has a mandatory string property called
"entityObjectName". In my test case, I create a MOC stack, add a new
SBDataSource (with NSEntityDescription's
"insertNewObjectForEntityForName:inManagedObjectContext"). The data
source's "entityObjectName is set in the "awakeFromInsert" method in
my SBDataSource's class definition. Up to that point, everything
works fine. Then I try to save the ManagedObjectContext and the
applicaiton goes into an infinite loop. I have overriden
"validateForInsert:" in my SBDataSource class, and the log shows
that this is called over and over; this might very well be a symptom
only, as I do not know exactly what method loops forever.
As anyone ever seen this? Any ideas what might be causing it? Any
idea how I could debug this??
Any help would be greatly appreciated!
You are most likely modifying a property of the object in the
validation method -- either with a generated accessor or by using key-
value coding. This causes the object state to be "dirtied" (different
than it was when the validation started) -- which means the context is
going to loop back around again and attempt to validate the object
AGAIN. And again. And again.
You cannot modify the state of the object in the validation methods --
only determine if it is in the appropriate state for the action.
(Also note -- if you try to call the primitiveValueForKey method
instead, you won't get any key-value observation notices for the
change.)
- matthew
_______________________________________________
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