我正在使用RestKit,我正在尝试使用RKPaginator。但是,我需要在URL请求中有一个日期时间字段。我正在构建以下requestString,它是一个NSString,并在:
中使用它RKPaginator *paginator = [objectManager paginatorWithPathPattern:requestString];
requestString is @“/api/rest/equipment/?count=3&limit=:perPage&offset=:offset&last_modified_date__gte=2014-03-31T17:20:26
然而,我一直在:
** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Parameters must be separated by non-parameter characters.'
这是由于":"在日期时间。所以......
我尝试过:
@“/api/rest/equipment/?count=3&limit=:perPage&offset=:offset&last_modified_date__gte=2014-03-31T17\\:20\\:26
然而,当我在以下函数中执行此操作时,我一直在RestKit中获取bad_access:
NSString *RKPathAndQueryStringFromURLRelativeToURL(NSURL *URL, NSURL *baseURL)
{
if (baseURL) {
if (! RKURLIsRelativeToURL(URL, baseURL)) return nil;
return [[URL absoluteString] substringFromIndex:[[baseURL absoluteString] length]];
} else {
// NOTE: [URL relativeString] would return the same value as `absoluteString` if URL is not relative to a baseURL
NSString *query = [URL query];
NSString *pathWithPrevervedTrailingSlash = [CFBridgingRelease(CFURLCopyPath((CFURLRef)URL)) stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
return (query && [query length]) ? [NSString stringWithFormat:@"%@?%@", pathWithPrevervedTrailingSlash, query] : pathWithPrevervedTrailingSlash;
}
}
答案 0 :(得分:0)
如果您的服务器对将:
编码为%3A
感到满意,那么就这样做。
否则,请查看创建RKPaginator
的子类,它添加了一个可以为日期设置的属性,并将其注入到路径模式中(与页面值的注入方式完全相同)。