backgroundSession is not working well with my app the download sometime stop and sometime done but the file saving fails
here is the code i am using just converted it today into swift but i am not sure if it's right
* AppDelegate *
var backgroundSessionCompletionHandler: ()! = Void()
func application(application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: () -> Void) {
self.backgroundSessionCompletionHandler = completionHandler()
}
* DownloadViewController *
func URLSessionDidFinishEventsForBackgroundURLSession(session: NSURLSession) {
let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
if (appDelegate.backgroundSessionCompletionHandler != nil) {
var completionHandler:Void = appDelegate.backgroundSessionCompletionHandler
appDelegate.backgroundSessionCompletionHandler = nil
}
NSLog("All backgroundSession Done")
}
is there anything wrong with the code or is there any other useful way to do this