mercredi 5 août 2015

IOS / Swift2 - List all files in directory


I have a server running nginx. I have a directory in my server where I have several audio files. I replaced my real url by "url".

How can I list them. I want to make a table with all of the files in that directory.

When I print weContent I get:

403 Forbidden

override func viewDidLoad() {
    super.viewDidLoad()

    let url = NSURL(string: "url")!

    //self.webView.loadRequest(NSURLRequest(URL: url))

    let task = NSURLSession.sharedSession().dataTaskWithURL(url) { (data, response, error) -> Void in

        // Will happen when task completes

        if let urlContent = data {

            let webContent = NSString(data: urlContent, encoding: NSUTF8StringEncoding)

            print(webContent)

            dispatch_async(dispatch_get_main_queue(), { () -> Void in

                self.webView.loadHTMLString(String(webContent!), baseURL: nil)

            })

        } else {

            // Show error message

        }

    }

    task.resume()

}

Thank you



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire