我有这段代码:
-(void)fetchCategoriesOnCompletion:(myCompletion) compblock{
Mapper *mapper = [Mapper new];
RKManagedObjectStore *store = [[ASLDataModel sharedDataModel] objectStore];
NSManagedObjectContext *context = store.mainQueueManagedObjectContext;
RKObjectManager *objectManager = [mapper mapReisCategorie];
NSString *urlString = [NSString stringWithFormat:@"/webservice/category/get/apikey/%@/language/%@",apikey,language];
[objectManager addFetchRequestBlock:^NSFetchRequest *(NSURL *URL) {
RKPathMatcher *pathMatcher = [RKPathMatcher pathMatcherWithPattern:[NSString stringWithFormat:@"webservice/category/get/apikey/%@/language/%@",apikey,language]];
NSDictionary *argsDict = nil;
BOOL match = [pathMatcher matchesPath:[URL relativePath] tokenizeQueryStrings:NO parsedArguments:&argsDict];
if (match) {
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Reiscategorie"];
return fetchRequest;
}
return nil;
}];
NSURLRequest *request = [objectManager requestWithObject:nil method:RKRequestMethodGET path:urlString parameters:nil];
NSLog(@"REQUEST URL IS %@",request.URL);
RKManagedObjectRequestOperation *operation = [objectManager managedObjectRequestOperationWithRequest:request managedObjectContext:context success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
NSError *error = nil;
BOOL success = [context save:&error];
if (!success) RKLogWarning(@"Failed saving managed object context: %@", error);
NSError *saveError = nil;
compblock(YES);
} failure:nil];
[objectManager enqueueObjectRequestOperation:operation];
}
这应该删除核心数据中我没有从JSON返回的对象。它曾经工作,但突然间没有? restkit有什么变化吗?