无法让 RKPathMatcher pathMatcher 匹配以删除孤立对象

Can't get RKPathMatcher pathMatcher to match for deleting orphans objects

我在删除路径匹配器从未匹配的孤立对象时遇到问题。如果路径中包含 2 个 id,我应该使用什么作为路径。谢谢

即 /api/getEntity/1234/123 其中 1234 是父 ID,123 是实体 ID

请求块如下:

  NSMutableURLRequest *request = [NSMutableURLRequest
 requestWithURL:[NSURL URLWithString:formattedUrl]];
     [sharedManager addFetchRequestBlock:^NSFetchRequest *(NSURL *URL) {

        RKPathMatcher *pathMatcher = [RKPathMatcher pathMatcherWithPattern::@"/api/getEntity/all/:parentEntityId/:entityId/"];         NSDictionary *argsDict = nil;
        BOOL match = [pathMatcher matchesPath:[URL relativePath] tokenizeQueryStrings:NO parsedArguments:&argsDict];
        if(match){
            NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
            NSEntityDescription *entity = [NSEntityDescription entityForName:@"SomeEntity" inManagedObjectContext:[RKManagedObjectStore
 defaultStore].mainQueueManagedObjectContext];
             [fetchRequest setEntity:entity];             return fetchRequest;
        }
        return nil;
    }];

这看起来像是您要加载的 URL 路径与 /api/getEntity/all/:parentEntityId/:entityId/ 的匹配器规范不匹配,因为您通常不会在 [=18= 上添加尾部斜线] 因为它表示一个目录,而你实际上正在加载一个 'page'。斜线和结构对匹配器很重要。

因此,删除结尾的斜杠。

一般来说,您的基础 URL 应该有一个尾部斜线,并且您的所有路径模式都不应该有前导或尾部斜线。