swiftswift3nsurlconnectiondelegatexcode8

Ambiguous use of 'connection(_:didReceive:)'


static let didReceiveResponseSelector : Selector = #selector((NSURLConnectionDataDelegate.connection(_:didReceive:)) as (NSURLConnectionDataDelegate) ->(NSURLConnection,URLResponse) -> ())

This code is returning error:

Ambiguous use of 'connection(_:didReceive:)'

I referred to the official evolution thread of Apple on GitHub, I respected the syntax but is not working:

Referencing the Objective-C selector of a method


Solution

  • solved, just add "?":

        static let didReceiveResponseSelector : Selector = #selector((NSURLConnectionDataDelegate.connection(_:didReceive:)) as ((NSURLConnectionDataDelegate) -> (NSURLConnection,URLResponse) -> void)?)