Download file on IOS - Swift

Asked

Viewed 115 times

0

People I am a short time programming for IOS using the language SWIFT.

I need to download a file from the web, I’m using Nsurlsessionconfiguration, but this object only works for IOS 8+. And I want the app to run on devices with IOS 7+. Does anyone know how to get around this?

func download(url: NSURL)
{
    self.url = url

    if #available(iOS 8.0, *) {
        let sessionConfig = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(url.absoluteString)
        let session = NSURLSession(configuration: sessionConfig, delegate: self, delegateQueue: nil)
        let task = session.downloadTaskWithURL(url)
        task.resume()
    } else {
        //Tratar para fazer download para versão 7
    }

1 answer

-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.