Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 3 and NSURLSession issue

Thanks to Apple my iOS 9 Project 'Swift 2.3' is completely unusable with iOS 10's 'Swift 3'...

I fixed almost everything except that I am having issue with using NSURLSession, Xcode is telling me that it has been renamed to URLSession, if I rename it Xcode will tell me:

use of undeclared type URLSession

Foundation is imported.

What is the issue?!

For example I am using it this way...

lazy var defaultSession: URLSession = {
    let configuration = URLSessionConfiguration.background(withIdentifier: "reCoded.BGDownload")
    configuration.sessionSendsLaunchEvents = true
    configuration.isDiscretionary = true
    let session = URLSession(configuration: configuration, delegate: self, delegateQueue, queue: nil)
    return session
}()

and even with the delegate methods the same issue.

like image 429
Raffi Avatar asked Jun 14 '16 15:06

Raffi


1 Answers

Try using Foundation.URLSession where ever you use URLSession.

like image 83
Jorn van Dijk Avatar answered Jan 04 '23 16:01

Jorn van Dijk