RestEngine クラスが確立されたときに、すべての responseDescriptors (8 つ) とマッピング (8 つ) を設定するプロジェクトがあります...各呼び出しではなく、事前にそれらを設定します。この良い習慣かどうかはわかりません。
問題は、ディスクリプタの 1 つがすべての結果をマッピングすべきではないときにマッピングしているように見えることです。
問題は私のthingDescriptorにあるか、次のルート(v1/things/:thingID\.json)である可能性があると思いますが、このルートはGETであるため、POSTリクエストがこのルートを通過するとは思いませんか?
これは、特定のクラスにマップされるべきではない、または特定のクラスにマップされたくない結果を取得している、私が作成している POST 要求です。
[[RKObjectManager sharedManager] postObject:nil
path:@"v1/things/request.json"
parameters:@{
@"auth_token" : self.accessToken,
@"api_key" : self.api_key,
@"lat" : lat,
@"lng" : lng
}
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
RKLogInfo(@"Post request of an Thing Request start tracking request update...");
<-- the mappingResult shows its mapped to a Thing class but I want server response to mapped to an NSDictionary instead?
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
RKLogError(@"Post request of an Thing Request failed with error: %@", error);
}];
セットアップされている私のマッピングは次のとおりです。
// Routes for Things
[objectManager.router.routeSet addRoute:[RKRoute routeWithClass:[Thing class]
pathPattern:@"v1/things/:thingID\\.json"
method:RKRequestMethodGET]];
[objectManager.router.routeSet addRoute:[RKRoute routeWithName:kRouteUpdateThingLoc
pathPattern:@"v1/things/update_location.json"
method:RKRequestMethodPOST]];
[objectManager.router.routeSet addRoute:[RKRoute routeWithClass:[Thing class]
pathPattern:@"v1/things.json"
method:RKRequestMethodPOST]];
// Register our mappings with the provider
RKResponseDescriptor *thingResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:thingMapping
pathPattern:@"v1/things.json"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
RKResponseDescriptor *thingDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:thingMapping
pathPattern:@"v1/things/:thingID.json"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];