gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 02:16:58 25 4
gpt4 key购买 nike

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

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

请求 block 如下:

  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/ 的匹配器规范不匹配,因为您通常不会将URL 上的尾部斜杠表示目录,并且您实际上正在加载“页面”。斜杠和结构对于匹配器来说很重要。

因此,删除结尾的斜杠。

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

关于ios - 无法让 RKPathMatcher pathMatcher 匹配以删除孤立对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28649591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com