Before iOS8 was released, I downloaded the iOS8 SDK to see how my application would work. Sometimes my application needs to download data from the server, and I use NSUrlSession for it. And now, when the application preparing the session for download, the following warning appears:
+backgroundSessionConfiguration: is deprecated. Please use +backgroundSessionConfigurationWithIdentifier: instead +backgroundSessionConfiguration: is deprecated. Please use +backgroundSessionConfigurationWithIdentifier: instead .
After that, the application will shut down with the following exception:
Unable to cast object of type 'MonoTouch.Foundation.NSUrlSessionTask' (Objective-C type: '__NSCFBackgroundDownloadTask') to type 'MonoTouch.Foundation.NSUrlSessionDownloadTask'. Additional information: Selector: URLSession:downloadTask:didFinishDownloadingToURL: Method: Microsoft.Synchronization.ClientServices.NSUrlDownloadDelegate:DidFinishDownloading (MonoTouch.Foundation.NSUrlSession,MonoTouch.Foundation.NSUrlSessionDownloadTask,MonoTouch.Foundation.NSUrl)
Code for creating NSUrlSession:
NSUrlSessionConfiguration sessionConfiguration = NSUrlSessionConfiguration.BackgroundSessionConfiguration(urlSessioinId); NSUrlDownloadDelegate downloadDelegate = new NSUrlDownloadDelegate(); NSUrlSession downloadSession = NSUrlSession.FromConfiguration(sessionConfiguration, downloadDelegate, new NSOperationQueue());
Thanks for any help!
source share