Trouble With NSURLSession...
Trouble With NSURLSession...
- Subject: Trouble With NSURLSession...
- From: "Peters, Brandon" <email@hidden>
- Date: Wed, 17 Jun 2015 02:45:36 +0000
- Thread-topic: Trouble With NSURLSession...
Here is the exact compiler message:
swift:20:26: Cannot find an initializer for type 'NSURLSession' that accepts an argument list of type '(configuration: NSURLSessionConfiguration, delegate: HSNDataManager.Type, delegateQueue: nil)'
Hello,
I am creating a class to handle downloading my app’s data. I am using Xcode with iOS 8.4 SDK and I keep getting from the compiler that there is no initializer for NSURLSession that accepts the list of arguments I am using:
import UIKit
class HSNDataManager: NSObject, NSURLSessionDelegate, NSURLSessionTaskDelegate,
NSURLSessionDownloadDelegate {
static let dataManager = HSNDataManager()
class func getRemoteData() {
// url session configuration
let urlSessionConfiguration = NSURLSessionConfiguration.defaultSessionConfiguration()
// create url session for downloading our sites database file
var urlSession = NSURLSession(configuration: urlSessionConfiguration, delegate: self, delegateQueue: nil)
// server location with file name
if let url = NSURL(string: HSNConstants.sitesDBFileName) {
// task type for location
let downloadSessionTask = urlSession.downloadTaskWithURL(url)
// start downloading DB
downloadSessionTask.resume()
}
}
func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didResumeAtOffset fileOffset: Int64, expectedTotalBytes: Int64) {
}
func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
}
func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {
}
func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?) {
}
}
But the signature appears in the documentation/API reference. Why would the compiler say this when it actually compiled fine when the code snippet resided in another .swift module?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden