Here is my simple swift class:
class SessionInitTest: NSObject, NSURLSessionDataDelegate {
let session: NSURLSession!
override init() {
super.init()
session = NSURLSession(configuration: nil, delegate: self, delegateQueue: nil)
}
}
the Xcode complaints that in the line of super.init()
:"Property 'self.session' not initialized at super.init call". And the init of session:"Immutable value 'self.session' may only be initialized once". According to need self to set all constants of a swift class in init, why session is not set to nil before super.init()
?