Unable update UILable using dispatch_async in swift iOS -


i setting json string value uilabel using dispatch_async method. unable show updated value , when printing label text, showing updated value. here code-

 dispatch_async(dispatch_get_main_queue(), {                      self.extract_json(data!)                 })   func extract_json(jsondata:nsdata) {     let json: anyobject?     {         json = try nsjsonserialization.jsonobjectwithdata(jsondata, options: [])         print("full data \(json!)")     } catch {         json = nil         return     }     let user_object = json!["opportunity_master"] as! nsarray     let data_block = user_object[0] as? nsdictionary     self.opp_title = (data_block!["opportunity_title"] as? string)!          print(self.opp_title)         <-- **here updating uilabel**-->          self.event_title.text = self.opp_title         self.event_title.setneedsdisplay()          print("event title label \(self.event_title.text)") } 

i unable update values, please suggest other method implement . thank you

while updating label text use :-

dispatch_async(dispatch_get_main_queue(), {  self.event_title.text = self.opp_title self.event_title.setneedsdisplay()  }) 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -