Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.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 上载图像时获取错误域-3840_Ios_Swift_Api - Fatal编程技术网

Ios 上载图像时获取错误域-3840

Ios 上载图像时获取错误域-3840,ios,swift,api,Ios,Swift,Api,使用json解析API调用将图像上载到服务器的API post请求中出现错误3480 错误域=NSCOCAERRORDOMAIN Code=3840“无值”。用户信息={NSDEBUGSCRIPTION=无值。} 当我调用此函数时,会显示错误,并且此API不会在我的设备中运行 我曾尝试将URL转换为字符串,并尝试在其他流中调用此函数,但效果良好 这是上传配置文件图像的post API请求,我在这次调用中遇到错误 当我得到的响应为false时,我可以运行API调用其结果的进一步代码,下面是API调

使用json解析API调用将图像上载到服务器的API post请求中出现错误3480

错误域=NSCOCAERRORDOMAIN Code=3840“无值”。用户信息={NSDEBUGSCRIPTION=无值。}

当我调用此函数时,会显示错误,并且此API不会在我的设备中运行

我曾尝试将URL转换为字符串,并尝试在其他流中调用此函数,但效果良好

这是上传配置文件图像的post API请求,我在这次调用中遇到错误


当我得到的响应为false时,我可以运行API调用其结果的进一步代码,下面是API调用post请求的代码,只有JSON解析

如果让PickeImage=info[UIImagePickerControllerEditedImage]显示为,则显示editImage函数代码?UIImage{userImage.contentMode=.scaleToFill userImage.image=PickeImage变量数据:NSData!如果imageName.后缀(3)=“png”| | | imageName.后缀(3)==“png”{data=UIImagePNGRepresentation(PickeImage)!作为NSData打印(“profiledata1/(字符串(描述:数据))”)}否则{data=UIImageJPEGresentation(PickeImage,1)!as NSData}imageOfUser=UIIMAGEPNGRESPRESSION(pickedImage)数据。写入(toFile:localPath,ATOMICALY:true)userImageUrl=URL.init(fileURLWithPath:localPath)}以上代码在从gallery或camera@Scriptable拍摄的图像之后
func updateImageApiCall() {

    self.userApi.editImage(userId:UserDefaults.standard.value(forKey: "UserID") as! String, profilePhoto: userImageUrl!, completion:{(response, error) in
       let data = response?.data(using: .utf8)!
    do {
        let jsonObj = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! [String: Any]

        if jsonObj["error"] as! Bool == false {
              let data = self.imageOfUser
              UserDefaults.standard.set(data, forKey: "userImage")
              Global.sharedInstance.saveImageDocumentDirectory(data!)

              self.hideLoader()
              self.showLoader(withMsg: "fetching information...")
              self.getUserApiCall()
         }

    } catch {
        print("error->\(error)")
    }
 })
}