ios - Swift - UILabel from URL -
i wanted know if it's possible load text in label url.
i going try , use nsurl pull in .txt file stored online.
would know how implement swift?
thanks
if don't want use sessions, can use simpler nsurlconnection class, this:
let url = nsurl(string: "https://wordpress.org/plugins/about/readme.txt") let request = nsurlrequest(url: url!) nsurlconnection.sendasynchronousrequest(request, queue: nsoperationqueue.mainqueue()) {(response, data, error) in println(nsstring(data: data, encoding: nsutf8stringencoding)) dispatch_async(dispatch_get_main_queue()) { // stuff on ui thread self.textfield.text = nsstring(data: data, encoding: nsutf8stringencoding)! string return } }
Comments
Post a Comment