Hi i have updated RestKit from 0.10.2 to 0.20.3. After updating now when objects are missing from web service, RestKit not deleting them from local storage. I know it is support
Finally solved the problem by debugging RestKit step by step and found this code in RKManagedObjectRequestOperation.m
if (! [[self.HTTPRequestOperation.request.HTTPMethod uppercaseString] isEqualToString:@"GET"]) {
RKLogDebug(@"Skipping deletion of orphaned objects: only performed for GET requests.");
return YES;
}
Oh! RestKit doesn't delete orphan objects when the request method is POST
. I changed the web services the accept GET
request too and it worked perfectly.
Secondly i was using predicate
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"user_id == %@", [DBUser currentUser].user_id];
It was wrong, to delete all objects except current user, i had to append NOT
operator, like this
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"user_id != %@", [DBUser currentUser].user_id];
So predicate
doesn't mean what you want, but it is what you don't want.