AFNetwoking with swift 3.0 & xcode 8 : POST Request & GET Request -


i trying parse data using afnetworking & swift 3.0 , xcode 8.0 getting error below.below code works fine swift 2.3 not working in 3.0

or if there know afnetworking & swift 3.0 using xcode 8.0 post & request please tell me. simple example. in advance

you can see below error.

enter image description here

 func callapi(apiname: string, param: [string : anyobject]?, data: nsdictionary?, withmethod type: string, completionhandler:@escaping (_ code: int, _ error:nserror?, _ response:anyobject?) -> void)      {          mbprogresshud.showadded(to: appdelegateobj.window, animated: true)         let str_url : string = khostpath+apiname          let manager: afhttpsessionmanager = afhttpsessionmanager()          if (type == kreq_post) {              manager.post(str_url, parameters: param, constructingbodywithblock: { (formdata: afmultipartformdata!) in                  if data?.allvalues.count != 0 && data != nil                 {                      let fileurl = nsurl(fileurlwithpath: (data?.valueforkey("filepath"))! as! string)                     try! formdata.appendpartwithfileurl(fileurl, name: (data?.valueforkey("key"))! as! string)                 }                  }, progress: { (nsprogress) in                  }, success: { (task:urlsessiondatatask, responseobject) -> void in                      completionhandler(code: 1, error: nil, response:responseobject)                     mbprogresshud.hidehudforview(appdelegateobj.window, animated: true)                  }, failure: { (task:urlsessiondatatask?, error:nserror) -> void in                      completionhandler(code: 0, error: error, response:nil)                     mbprogresshud.hidehudforview(appdelegateobj.window, animated: true)             })         }         else {              manager.get(str_url, parameters: param, progress: { (nsprogress) in                  }, success: { (task:urlsessiondatatask, responseobject) -> void  in                      completionhandler(code: 1, error: nil, response:responseobject)                     mbprogresshud.hidehudforview(appdelegateobj.window, animated: true)                  }, failure: { (task:urlsessiondatatask?, error:nserror) -> void  in                      completionhandler(code: 0, error: error, response:nil)                     mbprogresshud.hidehudforview(appdelegateobj.window, animated: true)             })         }     } 

but getting error

cannot convert value of type (urlsessiondatatask?,nserror)->void expected argument type '((urlsessiondatatask?,nserror)->void)?' 

change error type nserror error. type compatibility changed swift2.3 swift 3.0


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -