1

I have a function to retrieve data from an API using an URL link.

Everything works on iOS 8 but when I run it on a device with iOS 7, the following bit of swift code fails and the app crashes - the last line (when setting the session configuration) is the one that makes it crash.

I don't understand why, is it some feature not available in iOS 7 and how can I fix it?

var defaultConfigObject = NSURLSessionConfiguration.defaultSessionConfiguration()
defaultConfigObject.allowsCellularAccess = true

var session:NSURLSession = NSURLSession()
session = NSURLSession(configuration: defaultConfigObject)
sachalondon
  • 165
  • 1
  • 11
  • 1
    What is the exception message? – Paulw11 Jan 10 '15 at 12:11
  • Why are you doing this declaration and definition in two lines `var session:NSURLSession = NSURLSession() session = NSURLSession(configuration: defaultConfigObject)`. Try doing this whole thing like this `var session:NSURLSession = NSURLSession(configuration: defaultConfigObject)` – Krishna Jan 10 '15 at 12:32

0 Answers0