0
所以這是我想明白了什麼:通知中心發佈更新主線程上的UI元素?
例子:
func viewDidLoad(){
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(self.didUpdateHistory), name: NSNotification.Name.init("didUpdateHistory"), object: nil)
}
func didUpdateHistory(){
//Update some UI elements
}
現在我的問題是,如果我張貼在我的項目從某個類的通知,並且觸發不造成UI元素我是否還需要將doUpdateHistory函數中的任何內容與主要關閉進行封裝,還是應該自動打包該郵件調用?
此外,您是在哪裏添加觀察者以及從哪裏發佈通知?