[Solved] NSURL convert mistake in Swift


If you want to display the content present in your URL after we hit your URL in browser, we can do the following

let url = NSURL(string: "http://atakaractakip.co.nf/atakdeneme.txt")!
    let data = NSData(contentsOfURL: url)
    if data != nil {
        if let content = String(data: data!, encoding: NSUTF8StringEncoding) {

        //It will display Onay AKPINAR as this is the content in your URL
        self.myLabel?.text = content
        }
    }

Or if you just want to display your url as text you can use

//It will display your url in label i.e. http://atakaractakip.co.nf/atakdeneme.txt
self.myLabel?.text = url.absoluteURL

2

solved NSURL convert mistake in Swift