Is URLSession init(configuration:delegate:delegateQueue:) Working

Is URLSession init(configuration:delegate:delegateQueue:) Working

when I try:


var configuration = URLSessionConfiguration.default

var session = URLSession(configuration: configuration, delegate: self, queue: nil)


I get errors and XCode want me to change methods

Replies

When I put this code into a new iOS app test project, Xcode gives the following error:

…/ViewController.swift:17:33: error: incorrect argument label in call (have 'configuration:delegate:queue:', expected 'configuration:delegate:delegateQueue:')
        var session = URLSession(configuration: configuration, delegate: self, queue: nil)
                                ^                                              ~~~~~
                                                                              delegateQueue

That seems pretty self explanatory and, if not, Xcode gives you a fix-it to make the change.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

In the light of day everything become clearer.


I was trying to implement some old example for implementing the delegate and the methods started with "URLSession(" and for some reason XCode could not see the Foundation definitions. Using "Foundation.URLSession(" allowed me to use the method, but fixing the actual delegate methods fixed the real problem.