ios - AFHTTPRequestOperation setCacheResponseBlock Cannot convert value of type -


i’m using afhttprequestoperation in swift :

let operation : afhttprequestoperation? = manager.get(requesturl, parameters: nil,             success: { (operation:afhttprequestoperation!, responseobject:anyobject!) -> void in  ... ... ...                 success(downloadeditems: responseobject)             }, failure: { (operation: afhttprequestoperation!, error: nserror!) in                 failure(responsefromcache: responsefromcache, error: error);         }) 

and i’m using setcacheresponseblock application specific purpose (etag etc.)

operation!.setcacheresponseblock { (connection: nsurlconnection, cachedresponse: nscachedurlresponse) -> nscachedurlresponse in print("returns:200") responsefromcache = false return cachedresponse }

everything ok until updating xcode new version xcode7.1.

here problem, error when build application after update :

cannot convert value of type '(nsurlconnection, nscachedurlresponse) -> nscachedurlresponse' expected argument type '((nsurlconnection!, nscachedurlresponse!) -> nscachedurlresponse!)!' 

how fix this?

after checking error message understand wrong parameters. check method’s declaration in xcode , understand method’s declaration updated :

func setcacheresponseblock(block: ((nsurlconnection!, nscachedurlresponse!) -> nscachedurlresponse!)!) 

i updated method :

  operation!.setcacheresponseblock { (connection: nsurlconnection!, cachedresponse: nscachedurlresponse!) -> nscachedurlresponse! in             print("returns:200")             responsefromcache = false             return cachedresponse         } 

and happy ending build succeeded message in xcode. hope someone.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -