NSOperation mainQueue没有被执行

时间:2016-06-17 11:10:03

标签: ios swift nsoperation nsoperationqueue

class AsyncOperation : NSOperation {
    override func main () {
        print("In the user queue")
        NSOperationQueue.mainQueue().addOperationWithBlock({
            print("main block")
        })
    }
}
let queue = NSOperationQueue()
let operation = AsyncOperation();
queue.addOperation(operation)

它打印In the user queue但不打印main block。由于我要添加到主队列,我希望它能够被执行。我是否必须开始执行队列?

0 个答案:

没有答案