ios - CoreData detecting deleted entity after save -
this question has answer here:
if delete cd entity , save mod
[self.moc deleteobject:(nsmanagedobject *)somecdentity]; [self savemoc];
the pointers cd entity become faults
by trying accessing fault or ask isdeleted,
'coredata not fulfill fault
the problem is, save mod, isdeleted doesn't work more
so how can detect if entity removed? because asking isfault, doesn't indicate deleted... , cannot use isdeleted
i found in osx oriented thread
how can tell whether `nsmanagedobject` has been deleted?
- (bool) entitywasdeleted:(someentity *)someentity { return ((someentity == nil) || ([self.moc existingobjectwithid:someentity.objectid error:null] == nil)); }
beware : don't use code bellow, might not work
if (managedobject.managedobjectcontext == nil) { // assume managed object has been deleted = might not work }
Comments
Post a Comment