CoreData - isDeleted behavior question
CoreData - isDeleted behavior question
- Subject: CoreData - isDeleted behavior question
- From: Ryan Britton <email@hidden>
- Date: Fri, 22 Jul 2005 13:41:35 -0700
I have a situation where a subclass of NSManagedObject is removed
from a context and then potentially re-inserted when an undo
operation is triggered. This is not using the existing undo
capabilities of the context because there does not appear to be an
easy way to group changes together into a single undo call.
The initial value for - isDeleted is NO as it should be. It's also
YES after - deleteObject is called as it should be. However, after
it is re-inserted, it is still YES. My question is, is this the
intended behavior? Or should - isDeleted return NO upon re-insertion?
Here's a quick test for it:
- (void)testAddRemovedObject
{
NSManagedObjectContext *context = [[AppDelegate
sharedAppDelegate] managedObjectContext];
File *newFile = [NSEntityDescription
insertNewObjectForEntityForName:@"File" inManagedObjectContext:context];
[newFile setValue:@"/" forKey:@"path"];
STAssertFalse([newFile isDeleted], @"Inital Value: File should
not be marked as deleted but is");
[context deleteObject:newFile];
STAssertTrue([newFile isDeleted], @"After Delete: File should be
marked as deleted but isn't");
[context insertObject:newFile];
STAssertFalse([newFile isDeleted], @"Re-added: File should not
be marked as deleted but is");
}
The return for this is:
error: -[AddExistingBackupTask testAddRemovedObject] : "[newFile
isDeleted]" should be false. Re-added: File should not be marked as
deleted but is
_______________________________________________
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