更新时间:2023-02-23 10:53:42
IIRC,斜杠应该在URL的查询部分正确解释。你测试看看它仍然工作没有编码的斜杠?否则,请执行以下操作:
IIRC, slashes should be interpreted properly when they're in the query part of a URL. Did you test to see if it still works without encoded slashses? Otherwise, do something like:
if ([args isKindOfClass:[NSDictionary class]]) {
for (NSString *key in [args allKeys]) {
NSString *value = [(NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)[args objectForKey:key], NULL, CFSTR("/?&:=#"), kCFStringEncodingUTF8) autorelease];
[url appendString:[NSString stringWithFormat:@"&%@=%@", key, value]];
[value release];
}
}
return url;
注意CFURLCreateStringByAddingPercentEscapes的第4个参数的值。
Note the value of the 4th argument to CFURLCreateStringByAddingPercentEscapes.