Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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 api目标c调用web服务时出错_Ios_Objective C_Iphone_Rest_Web Services - Fatal编程技术网

Ios 使用restkit api目标c调用web服务时出错

Ios 使用restkit api目标c调用web服务时出错,ios,objective-c,iphone,rest,web-services,Ios,Objective C,Iphone,Rest,Web Services,我正在尝试调用web服务并上传图像 映射中有一个问题,我花了很多时间都没有成功。我得到的错误是: Error Domain=org.restkit.restkit.ErrorDomain Code=1001“不可映射 在搜索的关键路径中找到了对象表示。“ UserInfo={NSLocalizedDescription=没有可映射的对象表示形式 在搜索的关键路径中找到。NSLocalizedFailureReason= 映射操作找不到任何嵌套对象表示形式 在搜索的关键路径处:用户输入到 发现映射

我正在尝试调用web服务并上传图像

映射中有一个问题,我花了很多时间都没有成功。我得到的错误是:

Error Domain=org.restkit.restkit.ErrorDomain Code=1001“不可映射 在搜索的关键路径中找到了对象表示。“ UserInfo={NSLocalizedDescription=没有可映射的对象表示形式 在搜索的关键路径中找到。NSLocalizedFailureReason= 映射操作找不到任何嵌套对象表示形式 在搜索的关键路径处:用户输入到 发现映射程序包含位于 以下关键路径:message,success这可能表示您 已错误配置映射的键路径。键路径=null, 详细错误=()}

还有调用web服务的方法

[SVProgressHUD show];

        [delegate.objectManager.HTTPClient.defaultHeaders setValue:@"application/x-www-form-urlencoded" forKey:@"content-type" ];

        RKObjectMapping *responseMapping = [RKObjectMapping mappingForClass:[SignUpResponse class]]; //create response and request mapping

        [responseMapping addAttributeMappingsFromDictionary:@{@"phone": @"phone",
                                                              @"device_type": @"device_type",
                                                              @"device_token": @"device_token",
                                                              @"type": @"type",
                                                              @"email": @"email",
                                                              @"identity": @"identity",
                                                              @"date": @"date",
                                                              @"status": @"status",
                                                              @"name": @"name",
                                                              @"activation": @"activation",
                                                              @"image": @"image",
                                                              @"id": @"id"
                                                              }];

        RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:responseMapping
                                                                                                method:RKRequestMethodPOST
                                                                                           pathPattern:@"AgentRegister"
                                                                                               keyPath:@"user"
                                                                                           statusCodes:[NSIndexSet indexSetWithIndex:200]];

        [delegate.objectManager.defaultHeaders setValue:@"application/x-www-form-urlencoded" forKey:@"content-type" ];
        delegate.objectManager.requestSerializationMIMEType =RKMIMETypeFormURLEncoded;


        [delegate.objectManager removeResponseDescriptor:responseDescriptor];

        [delegate.objectManager addResponseDescriptor:responseDescriptor];

        NSString *fcmToken = [FIRInstanceID instanceID].token;

        SignUpRequest *signUpRequest = [[SignUpRequest alloc]init];
        signUpRequest.phone = txtPhoneNumber.text;
        signUpRequest.email = txtEmail.text;
        signUpRequest.identity=txtIdOrCity.text;
        signUpRequest.device_type=@"IOS";
        signUpRequest.device_token=fcmToken;
        signUpRequest.type=@"1";


        UIImage *image = [UIImage imageNamed:@"Logo"];


        // Serialize the Article attributes then attach a file
        NSMutableURLRequest *request = [[RKObjectManager sharedManager] multipartFormRequestWithObject:signUpRequest method:RKRequestMethodPOST path:@"AgentRegister" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
            [formData appendPartWithFileData:UIImagePNGRepresentation(image)
                                        name:@"image"
                                    fileName:@"photo.png"
                                    mimeType:@"application/x-www-form-urlencoded"];
        }];

        RKObjectRequestOperation *operation = [[RKObjectManager sharedManager] objectRequestOperationWithRequest:request success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult){

            [SVProgressHUD dismiss];
            if(mappingResult.array.count !=0){
                [self performSegueWithIdentifier:@"goToVerify" sender:self];
            }else{

            }

            [delegate.objectManager removeResponseDescriptor:responseDescriptor];
        }failure:^(RKObjectRequestOperation *operation, NSError *error){
            [SVProgressHUD dismiss];
            NSLog(@"%@",error.description);
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@".."
                                                                           message:@"حدث خطاء ما .. حاول مرة اخري" preferredStyle:UIAlertControllerStyleAlert];

            UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

            }];
            [alert addAction:okAction];
            [self presentViewController:alert animated:YES completion:nil];
            [delegate.objectManager removeResponseDescriptor:responseDescriptor];

        }];
        [[RKObjectManager sharedManager] enqueueObjectRequestOperation:operation];

    }
[SVProgressHUD show];
[delegate.objectManager.HTTPClient.defaultHeaders设置值:@“应用程序/x-www-form-urlencoded”forKey:@“内容类型”];
RKObjectMapping*responseMapping=[RKObjectMappingForClass:[SignUpResponse class]]//创建响应和请求映射
[ResponseMappingAddAttributeMappingsFromDictionary:@{@“phone”:@“phone”,
@“设备类型”:@“设备类型”,
@“设备令牌”:@“设备令牌”,
@“类型”:@“类型”,
@“电子邮件”:@“电子邮件”,
@“身份”:@“身份”,
@“日期”:“日期”,
@“状态”:@“状态”,
@“名称”:@“名称”,
@“激活”:@“激活”,
@“图像”:@“图像”,
@“id”:@“id”
}];
RKResponseDescriptor*responseDescriptor=[RKResponseDescriptor responseDescriptor WithMapping:responseMapping
方法:RKRequestMethodPOST
路径模式:@“AgentRegister”
密钥路径:@“用户”
状态代码:[NSIndexSet indexSetWithIndex:200]];
[delegate.objectManager.defaultHeaders设置值:@“应用程序/x-www-form-urlencoded”forKey:@“内容类型”];
delegate.objectManager.requestSerializationMIMEType=RKMIMETypeFormURLEncoded;
[delegate.objectManager removeResponseDescriptor:responseDescriptor];
[delegate.objectManager添加responseDescriptor:responseDescriptor];
NSString*fcmToken=[FIRInstanceID instanceID].token;
SignUpRequest*SignUpRequest=[[SignUpRequest alloc]init];
signUpRequest.phone=txtPhoneNumber.text;
signUpRequest.email=txtEmail.text;
signUpRequest.identity=txtIdOrCity.text;
signUpRequest.device_type=@“IOS”;
signUpRequest.device_token=fcmToken;
signUpRequest.type=@“1”;
UIImage*image=[UIImage ImageName:@“Logo”];
//序列化项目属性,然后附加一个文件
NSMutableURLRequest*request=[[RKObjectManager sharedManager]multipartFormRequestWithObject:signUpRequest方法:RKRequestMethodPOST路径:@“AgentRegister”参数:nil constructingBodyWithBlock:^(id formData){
[formData appendPartWithFileData:UIImagePNGRepresentation(图像)
名称:@“图像”
文件名:@“photo.png”
mimeType:@“application/x-www-form-urlencoded”];
}];
RKObjectRequestOperation*操作=[[RKObjectManager sharedManager]objectRequestOperationWithRequest:请求成功:^(RKObjectRequestOperation*操作,RKMappingResult*映射结果){
[SVD解散];
if(mappingResult.array.count!=0){
[self-PerformsgueWithIdentifier:@“goToVerify”发件人:self];
}否则{
}
[delegate.objectManager removeResponseDescriptor:responseDescriptor];
}失败:^(RKObjectRequestOperation*操作,NSError*错误){
[SVD解散];
NSLog(@“%@”,错误说明);
UIAlertController*警报=[UIAlertController alertControllerWithTitle:@]
消息:“首选样式:UIAlertControllerStyleAlert];
UIAlertAction*okAction=[UIAlertAction actionWithTitle:@“确定”样式:UIAlertActionStyleDefault处理程序:^(UIAlertAction*\U非空操作){
}];
[警报添加操作:确定操作];
[自我呈现视图控制器:警报动画:是完成:无];
[delegate.objectManager removeResponseDescriptor:responseDescriptor];
}];
[[RKObjectManager sharedManager]排队ObjectRequestOperation:operation];
}

此错误告诉您,
用户路径上没有可用的内容。例如,如果您的响应是JSON,则没有名为
user
的根键,只有
message
success

{
“用户”: