2012-05-11 6 views
2

RestKitに問題がありますRKObjectLoaderは配列パラメータでパスを切り捨てます

私はパラメータ文字列配列で送信しようとしています。このようにしてください。私は、サーバー上のコンソールを見ると、私は

は/タグ?型%5B%の5D =%D0%A0%D0%BE%D0%B4%D1」GET開始を参照

RKObjectMapping* tagMapping = [[RKObjectManager sharedManager].mappingProvider 
    objectMappingForClass:[RKTag class]]; 
NSArray *tags = [NSArray arrayWithObjects:@"Home", @"Relation", nil]; 
NSDictionary *dictParams = 
    [NSDictionary dictionaryWithObject:tags forKey:@"type"]; 

NSString *resourcePath = [[NSString stringWithString:@"/tags"] 
    stringByAppendingQueryParameters:dictParams]; 
[_m loadObjectsAtResourcePath:resourcePath usingBlock:^(RKObjectLoader *loader) { 
    [loader setObjectMapping:tagMapping]; 
    [loader setMethod:RKRequestMethodGET]; 
    [loader setDelegate:delegate]; 
}]; 

しかし、 %81%D1%82%D0%B2%D0%B5%D0%BD%D0%BD%D1%8B%D0%B5%20%D0%BE%D1%82%D0%BD%D0%BE%D1 2012年5月11日16:30:54 +0400 でJSON としてtagsController#indexによる処理が行われました。パラメータ:{"type(%)% "=> [" Home "]}

RKObjectLoaderの初期化時に、メソッドl oaderWithResourcePath、私の配列を切り詰めるもの

これを修正するには?

答えて

0

私はRKUrlClass

- (id)initWithBaseURL:(NSURL *)theBaseURL resourcePath:(NSString *)theResourcePath queryParameters:(NSDictionary *)theQueryParameters { 
    NSDictionary *resourcePathQueryParameters = [theResourcePath queryParameters]; 
    NSMutableDictionary *mergedQueryParameters = [NSMutableDictionary dictionaryWithDictionary:[theBaseURL queryParameters]]; 
    [mergedQueryParameters addEntriesFromDictionary:resourcePathQueryParameters]; 
    [mergedQueryParameters addEntriesFromDictionary:theQueryParameters]; 

    // Build the new URL path 
    NSRange queryCharacterRange = [theResourcePath rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"?"]]; 
    NSString *resourcePathWithoutQueryString = (queryCharacterRange.location == NSNotFound) ? theResourcePath : [theResourcePath substringToIndex:queryCharacterRange.location]; 
    NSString *baseURLPath = [[theBaseURL path] isEqualToString:@"/"] ? @"" : [[theBaseURL path] stringByStandardizingPath]; 
    NSString *completePath = resourcePathWithoutQueryString ? [baseURLPath stringByAppendingString:resourcePathWithoutQueryString] : baseURLPath; 
    NSString* completePathWithQuery = [completePath stringByAppendingQueryParameters:mergedQueryParameters]; 

    // before 
    // NSURL* completeURL = [NSURL URLWithString:completePathWithQuery relativeToURL:theBaseURL]; 
    // after my edit 
    NSString *cPath = theResourcePath ? theResourcePath : baseURLPath; 
    NSURL* completeURL = [NSURL URLWithString:cPath relativeToURL:theBaseURL]; 

    if (!completeURL) { 
     RKLogError(@"Failed to build RKURL by appending resourcePath and query parameters '%@' to baseURL '%@'", theResourcePath, theBaseURL); 
     [self release]; 
     return nil; 
    } 

    self = [self initWithString:[completeURL absoluteString]]; 
    if (self) { 
     self.baseURL = theBaseURL; 
     self.resourcePath = theResourcePath; 
    } 

    return self; 
} 
を変更することでこの問題を解決します
関連する問題