ambiguous use of selector dataTask(with: completionHandler:)

Tushar

I'm trying to get a selector of the dataTask(with:completionHandler:) method defined in URLSession which uses URLRequest object like below, but getting error as there are two methods with slightly two different params names (overloaded methods - 1. one uses URLRequest object as param and another uses URL) :

let dataTaskSelector = #selector(URLSession.dataTask(with: completionHandler:))

I have tried a different approach like below (mentioned in https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md ) but it's also giving same error :

let mySelector = #selector((URLSession.dataTask(with: completionHandler:)) as (URLSession) -> (URLRequest, (Data?, URLResponse?, Error?) -> Swift.Void) -> URLSessionDataTask)

ここに画像の説明を入力してください

私は最新のXcodeとswift3を使用しています。残念ながら、これに関する同様の例を含む適切なドキュメントはこれまで見つかりませんでした。助けてください。

前もって感謝します!

ニラブD

selectorこのように書くことができます

let selector = #selector((URLSession.dataTask(with:completionHandler:)) as (URLSession) -> (URLRequest, @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask)

この#selector チュートリアルは、解決策を得るのに役立ちます。

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Ambiguous use of 'observeSingleEvent(of: with:)

分類Dev

Use of overloaded operator ambiguous

分類Dev

Use of completionHandler(UIBackgroundFetchResultNewData) when doing a background refresh in iOS

分類Dev

Ambiguous use of init in Swift 2.2

分類Dev

Capybara / Ruby - Trying to get only the Text from all ambiguous css selector and convert it to string

分類Dev

Use trailing ampersand (&) as a class combination selector, not a descendant selector

分類Dev

Swift 3 and Xcode8 - Ambiguous use of init

分類Dev

Cannot Use parameter for Selector in Swift Class

分類Dev

Use JQuery Odd selector for separate ul tags

分類Dev

jQuery - Use multiple data search selector

分類Dev

JQuery: How to use a for loop variable in a jquery selector?

分類Dev

Is there a way to use the & on the same line as the parent selector?

分類Dev

NSAlert beginSheetModalForWindow:completionHandler:

分類Dev

Scrapy : Use selector (xpath) in ItemLoader 's output processor

分類Dev

How to use yield instead of print with scrapy selector and selenium?

分類Dev

J Query Simple Color Picker - use as background color selector

分類Dev

jQuery.on use with parent and child selectors vs just child selector

分類Dev

How can I use event.target.id as a jQuery selector?

分類Dev

NumPy Error: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

分類Dev

Getting Ambiguous use of 'reachabilityChanged' error after installing third party framework through cocoa pods?

分類Dev

Eigen with custom scalar types: Matrix multiplication with custom type fails with `use of overloaded operator '*' is ambiguous`

分類Dev

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() python

分類Dev

sendAsynchronousRequest:queue:completionHandlerの使用方法:

分類Dev

Deprecated: 'sendAsynchronousRequest:queue:completionHandler:' in iOS9

分類Dev

「completionHandler(true)」の説明方法

分類Dev

How to correctly use a curried selector function with react-redux's useSelector hook?

分類Dev

Ambiguous reference to member '=='

分類Dev

Ambiguous reference to member '=='

分類Dev

Example of ambiguous DateTimeOffset

Related 関連記事

  1. 1

    Ambiguous use of 'observeSingleEvent(of: with:)

  2. 2

    Use of overloaded operator ambiguous

  3. 3

    Use of completionHandler(UIBackgroundFetchResultNewData) when doing a background refresh in iOS

  4. 4

    Ambiguous use of init in Swift 2.2

  5. 5

    Capybara / Ruby - Trying to get only the Text from all ambiguous css selector and convert it to string

  6. 6

    Use trailing ampersand (&) as a class combination selector, not a descendant selector

  7. 7

    Swift 3 and Xcode8 - Ambiguous use of init

  8. 8

    Cannot Use parameter for Selector in Swift Class

  9. 9

    Use JQuery Odd selector for separate ul tags

  10. 10

    jQuery - Use multiple data search selector

  11. 11

    JQuery: How to use a for loop variable in a jquery selector?

  12. 12

    Is there a way to use the & on the same line as the parent selector?

  13. 13

    NSAlert beginSheetModalForWindow:completionHandler:

  14. 14

    Scrapy : Use selector (xpath) in ItemLoader 's output processor

  15. 15

    How to use yield instead of print with scrapy selector and selenium?

  16. 16

    J Query Simple Color Picker - use as background color selector

  17. 17

    jQuery.on use with parent and child selectors vs just child selector

  18. 18

    How can I use event.target.id as a jQuery selector?

  19. 19

    NumPy Error: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

  20. 20

    Getting Ambiguous use of 'reachabilityChanged' error after installing third party framework through cocoa pods?

  21. 21

    Eigen with custom scalar types: Matrix multiplication with custom type fails with `use of overloaded operator '*' is ambiguous`

  22. 22

    ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() python

  23. 23

    sendAsynchronousRequest:queue:completionHandlerの使用方法:

  24. 24

    Deprecated: 'sendAsynchronousRequest:queue:completionHandler:' in iOS9

  25. 25

    「completionHandler(true)」の説明方法

  26. 26

    How to correctly use a curried selector function with react-redux's useSelector hook?

  27. 27

    Ambiguous reference to member '=='

  28. 28

    Ambiguous reference to member '=='

  29. 29

    Example of ambiguous DateTimeOffset

ホットタグ

アーカイブ