这是我的项目之一满足:如何在dispatch_async中调试当前队列?
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
}
}
}
而且我想这dispatch_async
与队列没用在这里。我如何查看队列?我真的需要这里吗?我需要检查它是否与没有阻塞的队列相同。
上述功能是内部的UIViewController
子类,称为viewDidLoad
和viewDidAppear
UPDATE:
我知道,因为在IOS中的错误,在这里需要:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
dispatch_async(dispatch_get_main_queue()) {
self.presentOverlayController(selectViewController)
}
}
你要检查,如果该方法已经在主队列运行?请参阅http://stackoverflow.com/questions/5662360/gcd-to-perform-task-in-main-thread。但是,在主队列上调用viewDidLoad等。 –
奇怪的是,我从来没有这样做,如果你删除dispatch_async –