简体   繁体   中英

Delete Managed Object using Core data/Restkit

I have to delete local store data (orphaned objects) which is no longer returned by server. I am using the following code when initilializing object manager.

[objectManager addFetchRequestBlock:^NSFetchRequest *(NSURL *URL) {
            RKPathMatcher *pathMatcher = [RKPathMatcher pathMatcherWithPattern:@"/relative_path"];

            NSDictionary *argsDict = nil;
            BOOL match = [pathMatcher matchesPath:[URL relativePath] tokenizeQueryStrings:NO parsedArguments:&argsDict];
            if (match) {
                NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Articles"];
                return fetchRequest;
            }

            return nil;
        }];

In the above code, 'match' condition returns TRUE. But Fetch Request doesn't delete the orphaned objects which was not returned by the server.

您想使用此处记录的“获取请求块和删除孤立对象”方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM