0

I’m using AFHTTPRequestOperation in swift like this :

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 for application specific purpose (ETag etc.)

operation!.setCacheResponseBlock { (connection: NSURLConnection, cachedResponse: NSCachedURLResponse) -> NSCachedURLResponse in print("Returns:200") responseFromCache = false return cachedResponse }

Everything was OK until updating XCode to new version XCode7.1.

Here is my problem, I get this error when I build my application after update :

Cannot convert value of type '(NSURLConnection, NSCachedURLResponse) -> NSCachedURLResponse' to expected argument type '((NSURLConnection!, NSCachedURLResponse!) -> NSCachedURLResponse!)!'

How to fix this?

MGY
  • 7,245
  • 5
  • 41
  • 74

1 Answers1

0

After checking error message I understand something wrong with my parameters. I check method’s declaration in XCode and I understand method’s declaration just updated :

func setCacheResponseBlock(block: ((NSURLConnection!, NSCachedURLResponse!) -> NSCachedURLResponse!)!)

I updated my method like this :

  operation!.setCacheResponseBlock { (connection: NSURLConnection!, cachedResponse: NSCachedURLResponse!) -> NSCachedURLResponse! in
            print("Returns:200")
            responseFromCache = false
            return cachedResponse
        }

and another happy ending with build succeeded message in Xcode. Hope this will help someone.

MGY
  • 7,245
  • 5
  • 41
  • 74