0

I'm following Swift's already implemented proposal guide https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md to make an unambiguous selector declaration.

But the following code gives error:

amibiguous reference to member urlSession(_:dataTask:didBecome)"

enter image description here

let sel = #selector((URLSessionDataDelegate.urlSession(_:dataTask:didBecome:)) as (URLSessionDataDelegate) -> (URLSession, URLSessionDataTask, URLSessionDownloadTask) -> Void)

But after adding force unwrap, the error goes away:

let sel = #selector((URLSessionDataDelegate.urlSession(_:dataTask:didBecome:))! as (URLSessionDataDelegate) -> (URLSession, URLSessionDataTask, URLSessionDownloadTask) -> Void)

My question is - What is the correct way to make the selector here? Why does the error go away by adding force-unwrap? And am I doing it right by adding force unwrap here?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Tushar
  • 3,022
  • 2
  • 26
  • 26

0 Answers0