In my application i perform long task in background. So i used Grand Central Dispatch (GCD)
and update the UI in main Queue.
Here is my code
dispatch_async(dispatch_get_global_queue(Int(QOS_CLASS_BACKGROUND.value), 0), {
// perform long task
//update UI
dispatch_async(dispatch_get_main_queue(), {
self.Label.text = "value changed" // not work
self.collectionView.reloadData() // work properly
})
})
It will work fine. However when i move from my current ViewController
to NextViewController
and again back toViewController
background task is executed but my Label
will not change.
QUESTION: Please help me so i can update my UI when back from another ViewController
NOTE: for moving one ViewController to another the task is perform in main queue.
EDIT : here is a output of @Yuri code
2015-06-08 14:34:19.565 myApp[7726:1481939] before: self:Logic() `self.label:<myApp.ViewController: 0x15947e00>
2015-06-08 14:34:50.925 myApp[7726:1481925] after: self:Logic() self.label:<myApp.ViewController: 0x15947e00>`
Edit2 here is output of @Oyeoj
before: <UILabel: 0x16565c60; frame = (20 56; 104 18); text = 'Back up'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x16565eb0>>
after: <UILabel: 0x16565c60; frame = (20 56; 104 18); text = 'value changed'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x16565eb0>>