Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 停止Restkit映射所有结果_Ios_Objective C_Restkit - Fatal编程技术网

Ios 停止Restkit映射所有结果

Ios 停止Restkit映射所有结果,ios,objective-c,restkit,Ios,Objective C,Restkit,我有一个项目,当我的RestEngine类建立时,我正在设置所有ResponseDescriptor(其中8个)和映射(其中8个)。。。我在每次通话之前而不是在每次通话中设置它们。我不确定这是否是一个好的做法 问题是,我的一个描述符似乎在映射所有结果,而它不应该映射 我认为问题在于我的thingDescriptor,或者可能是以下路径(v1/things/:thingID\.json),但此路径是GET,因此我认为我的POST请求不会通过此路径? 下面是我正在发出的POST请求,它将结果映射到一

我有一个项目,当我的RestEngine类建立时,我正在设置所有ResponseDescriptor(其中8个)和映射(其中8个)。。。我在每次通话之前而不是在每次通话中设置它们。我不确定这是否是一个好的做法

问题是,我的一个描述符似乎在映射所有结果,而它不应该映射

我认为问题在于我的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);
                                        }];

像这样使用AFN网络:

    AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:@"v1/"];

    NSDictionary *parameters = @{
                                @"auth_token" : self.accessToken,
                                @"api_key" : self.api_key,
                                @"lat" : lat,
                                @"lng" : lng
                                };

    NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"things/request.json" parameters:parameters];

    AFJSONRequestOperation *opertaion = [AFJSONRequestOperation JSONRequestOperationWithRequest:responseObject success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
        NSLog(@"THIS IS A DICTIONARY (or array): %@", JSON);
    } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
        NSLog(@"if requestFailed");
    }];

像这样使用AFN网络:

    AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:@"v1/"];

    NSDictionary *parameters = @{
                                @"auth_token" : self.accessToken,
                                @"api_key" : self.api_key,
                                @"lat" : lat,
                                @"lng" : lng
                                };

    NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"things/request.json" parameters:parameters];

    AFJSONRequestOperation *opertaion = [AFJSONRequestOperation JSONRequestOperationWithRequest:responseObject success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
        NSLog(@"THIS IS A DICTIONARY (or array): %@", JSON);
    } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
        NSLog(@"if requestFailed");
    }];
上面的一些打字错误:

AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[[NSURL alloc] initWithString:@"http://my.herokuapp.com/"]];

NSDictionary *parameters = @{
                             @"api_key" : self.api_key,
                             @"acode" : code
                             };

NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"v1/users/approve_by_code.json" parameters:parameters];

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSLog(@"THIS IS A DICTIONARY (or array): %@", JSON);
    object:nil];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
    NSLog(@"if requestFailed");
}];

[operation start];
上面的一些打字错误:

AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[[NSURL alloc] initWithString:@"http://my.herokuapp.com/"]];

NSDictionary *parameters = @{
                             @"api_key" : self.api_key,
                             @"acode" : code
                             };

NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"v1/users/approve_by_code.json" parameters:parameters];

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSLog(@"THIS IS A DICTIONARY (or array): %@", JSON);
    object:nil];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
    NSLog(@"if requestFailed");
}];

[operation start];

我很难理解你的问题。是否要在不映射到对象的情况下发出POST请求?不要使用RestKit,RestKit将尝试将数据映射到对象。如果您只是在寻找json到nsdictionary的响应,请改用AFNetworking。这是RestKit在RestKit的对象映射下面使用的。如果我误解了我所害怕的,请告诉我。我不知道Restkit是否允许您在不映射的情况下进行调用。可能是这样,但这并不是它真正的目的。你应该已经在你的项目中有了AFNetworking,对吗?如果你不熟悉使用它,我可以给你一个快速的例子。请举个例子。谢谢我很难理解你的问题。是否要在不映射到对象的情况下发出POST请求?不要使用RestKit,RestKit将尝试将数据映射到对象。如果您只是在寻找json到nsdictionary的响应,请改用AFNetworking。这是RestKit在RestKit的对象映射下面使用的。如果我误解了我所害怕的,请告诉我。我不知道Restkit是否允许您在不映射的情况下进行调用。可能是这样,但这并不是它真正的目的。你应该已经在你的项目中有了AFNetworking,对吗?如果你不熟悉使用它,我可以给你一个快速的例子。请举个例子。谢谢