GCD转NSOperation,怎样更新UI?
hexx 2017-01-15 03:59:03 原来线程用GCD,由于无需关心上下文,所以直接在主线程里访问ViewController里的控件就可以更新UI。现在为实现复杂的功能,需使用函数,而GCD是block,是没有函数的,于是改用(NS)Operation,Operation有函数,但不知怎样实现以下语句:
let alertView = UIAlertController(title: "提示", message: "没连网络", preferredStyle: .alert)
let cancelViewAction = UIAlertAction(title: "确定", style: .cancel, handler: nil)
alertView.addAction(cancelViewAction)
self.present(alertView, animated: true, completion: nil)
最后一行的self应该是ViewController,怎样改?