How to access and refresh a UITableView from another class in Swift

后端 未结 4 587
清歌不尽
清歌不尽 2021-01-03 09:24

I have a tab bar application and a tab whose view controller is controlled by a UITableView class. I have a class that is used to download data from the server that then sav

4条回答
  •  轮回少年
    2021-01-03 10:09

    For Swift 3

    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "newDataNotificationForItemEdit"), object: nil)
    
    NotificationCenter.default.addObserver(self, selector: #selector(self.shouldReload), name: NSNotification.Name(rawValue: "newDataNotificationForItemEdit"), object: nil)
    
    func shouldReload() {
        self.tableView.reloadData()
    }
    

提交回复
热议问题