我有这个Swift代码(从Obj迁移过来)
NSOperationQueue().addOperationWithBlock({
print("WORKING...")
NSOperationQueue.mainQueue().addOperationWithBlock({
print("FINISHED")
})
})mainQueue块不执行(从未打印“已完成”)。它有什么问题?
发布于 2014-06-24 11:48:37
这段代码非常好,并且两个操作块都在执行,但是mainQueue操作块有时需要lil时间来执行,因为mainQueue将该块添加到主线程的操作队列中,但不能保证何时执行。该队列中可能还有其他项等待执行。
发布于 2015-12-04 14:15:42
我使用GCD,例如:
dispatch_async(dispatch_get_main_queue()) {
[weak self] in
self.collection.reloadData()
}https://stackoverflow.com/questions/24383654
复制相似问题