简体   繁体   English

使用核心数据/ Restkit删除托管对象

[英]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. 在上面的代码中,“ match”条件返回TRUE。 But Fetch Request doesn't delete the orphaned objects which was not returned by the server. 但是获取请求不会删除服务器未返回的孤立对象。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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