Question

I am using RestKit and I am trying to use the RKPaginator. However, I need to have a datetime field within the URL Request. I am building the following requestString, which is a NSString, and use it in:

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

However, I keep getting:

** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Parameters must be separated by non-parameter characters.'

This is due to the ":" in the datetime. So...

I tried with:

@“/api/rest/equipment/?count=3&limit=:perPage&offset=:offset&last_modified_date__gte=2014-03-31T17\\:20\\:26

however, I keep getting bad_access within the RestKit when I do that in the following function:

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;
    }
}
Was it helpful?

Solution

If your server is happy with encoding : as %3A then do that.

Otherwise, look at creating a subclass of RKPaginator which adds a property that you can set for the date and which is injected into the path pattern (in exactly the same way the page values are injected).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top