CoreData: Using willSave to update timestamps causes hang?
CoreData: Using willSave to update timestamps causes hang?
- Subject: CoreData: Using willSave to update timestamps causes hang?
- From: Jim Correia <email@hidden>
- Date: Mon, 2 May 2005 11:37:07 -0400
The NSManagedObject documentation says:
<http://developer.apple.com/documentation/Cocoa/Reference/
CoreData_ObjC/Classes/NSManagedObject.html#//apple_ref/doc/uid/
TP30001171-BBCGBABB>
willSave
- (void)willSave
Invoked automatically by the Core Data framework when the
receiver’s
managed object context is saved. It is commonly used to compute
persisted values from other transient values, to set timestamps,
and so
on. This method can have “side effects” on the persistent values.
When I use this to do that exactly - modify the last saved timestamp
of an object, I get a hang when saving. It appears that making the
change inside of willSave causes willSave to be called again.
- (void)willSave
{
[self setValue: [NSDate date] forKey: @"lastSavedDate"];
}
Sample project and full sample available at:
<http://homepage.mac.com/jimcorreia/tmp/WillSave.zip>
Am I doing something obviously wrong? Is this a bug (in which case
I'll write a radar.) Any workarounds?
Thanks,
Jim
_______________________________________________
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