I am making a method that will remove all of my NSManagedObjects that were not updated in the last sync.
- (void)removeStaleObjects {
// Delete objects that have not been updated in this sync.
NSPredicate *stalePredicate = [NSPredicate predicateWithFormat:@"updated < %@", self.syncStart];
NSArray *staleObjects = [Node MR_findAllWithPredicate:stalePredicate];
for (Node *n in staleObjects) {
[[NSManagedObjectContext MR_defaultContext] deleteObject:n];
}
}
The code keeps failing on the MR_findAll... line with
[__NSDate objCType]: unrecognized selector sent to instance
I have checked my syntax with the apple documentation and I am 99% positive that I am creating the predicate correctly, startDate is just
_startDate = [NSDate date];
that gets run prior to my sync. then after my sync I call
[self removeStaleObjects];
Does anyone know where I am messing up?
Update: I was able to get it to work by storing the update time as a double. However, I am still interested in getting it to work with NSDates so if anyone figures something out, please post it here.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…