Re: Trouble With NSURLSession...
Re: Trouble With NSURLSession...
- Subject: Re: Trouble With NSURLSession...
- From: "Peters, Brandon" <email@hidden>
- Date: Wed, 17 Jun 2015 02:55:58 +0000
- Thread-topic: Trouble With NSURLSession...
Figured it out: Needed to be ->
var urlSession = NSURLSession(configuration: urlSessionConfiguration, delegate: HSNDataManger.dataManager, delegateQueue: nil)
On Jun 16, 2015, at 10:42 PM, Peters, Brandon <email@hidden<mailto:email@hidden>> wrote:
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<mailto: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<http://lists.apple.com>
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
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