I'm having a hard time with this code: ------------------------ import Foundation
class MyDelegate : NSObject, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDownloadDelegate { func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) { } var backgroundSession: NSURLSession = { let config = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier("myident") let session = NSURLSession(configuration: config, delegate: self, delegateQueue: nil) return session }() } playground18.swift:14:23: error: cannot invoke initializer for type 'NSURLSession' with an argument list of type '(configuration: NSURLSessionConfiguration, delegate: MyDelegate -> () -> MyDelegate, delegateQueue: nil)' let session = NSURLSession(configuration: config, delegate: self, delegateQueue: nil) ^ playground18.swift:14:23: note: overloads for 'NSURLSession' exist with these partially matching parameter lists: (configuration: NSURLSessionConfiguration), () let session = NSURLSession(configuration: config, delegate: self, delegateQueue: nil) ^ ------------------------ What is the type of "self" in the initializer closure, and is there a way to refer to the enclosing class instance? I also had trouble locating this in the Swift 2 guide, if it's there at all. I can do it with a separate member function and call that in the initializer, but that introduces a lot of boilerplate, as well as creating a method I don't intend to ever be called separately. -- Rick Mann rm...@latencyzero.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com