我有以下映射:無法獲得RKPathMatcher *的PathMatcher以匹配刪除孤兒對象
RKResponseDescriptor *productionParametersPerEquipment = [RKResponseDescriptor responseDescriptorWithMapping:productionParameterMapping
pathPattern:@"/api/rest/productionparameters/?equipment=:equipment_id"
keyPath:@"objects"
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
,然後我有:
[objectManager addFetchRequestBlock:^NSFetchRequest *(NSURL *URL) {
RKPathMatcher *pathMatcher = [RKPathMatcher pathMatcherWithPattern:@"/api/rest/productionparameters/?equipment=:equipment_id"];
NSDictionary *argsDict = nil;
BOOL match = [pathMatcher matchesPath:[URL relativePath] tokenizeQueryStrings:NO parsedArguments:&argsDict];
NSString *productionParameterID;
if (match) {
productionParameterID = [argsDict objectForKey:@"id"];
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"ProductionParameter"];
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"identifier = %@", @([productionParameterID integerValue])]; // NOTE: Coerced from string to number
fetchRequest.sortDescriptors = @[ [NSSortDescriptor sortDescriptorWithKey:@"order" ascending:YES] ];
return fetchRequest;
}
return nil;
}];
但是,每當我打電話下面, 永遠不會匹配,因此我的孤兒永遠不會被刪除。有任何想法嗎?
[[RKObjectManager sharedManager] getObjectsAtPath:[NSString stringWithFormat:@"/api/rest/productionparameters/?equipment=%@",_equipment.identifier] parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult)
你能否提供更多關於如何做到這一點的信息?我對所有這些URL /匹配的東西都是新手。 – abisson
添加了一些示例代碼 – Wain
我試圖再次得到這個工作......我想知道是否有可能當我們用URL/api/rest/productionparameters(它將映射到ProductionParameters對象)獲取對象時,將addFetchRequestBlock僅比較ProductionParameters對象還是ProductionParameters的propertyMapping? – abisson