This is what I met in one of the projects:
private func updateBadgeView() {
dispatch_async(dispatch_get_main_queue()) {
if UIApplication.sharedApplication().applicationIconBadgeNumber > 0 {
self.newMessagesBadgeView.hidden = false
self.newMessagesCountLabel.text = String(UIApplication.sharedApplication().applicationIconBadgeNumber)
} else {
self.newMessagesBadgeView.hidden = true
}
}
}
And I suppose that dispatch_async
with that queue is useless here. How can I check the queue here? Do I really need here this block? I need to check if it is the same queue as without block.
The above function is inside subclass of UIViewController
and is called in viewDidLoad
and viewDidAppear
UPDATE:
I know that because of a bug in ios, it is needed here:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
dispatch_async(dispatch_get_main_queue()) {
self.presentOverlayController(selectViewController)
}
}