I am building an app to track BLE devices, and I have a delegate (in appDelegate) that updates the list of discovered devices over the bluetooth.
I need to display this
The problem is that ViewController()
is not your view controller. It is a new separate instance. You need to refer to your existing view controller.
So, as @matt pointed out, the problem was that I was instantiating a new ViewController in AppDelegate, so to solve this I did:
let navController = self.window?.rootViewController as! UINavigationController
newViewController = navController.visibleViewController as! ViewController
to, as I understand it, pull the reference to the existing ViewController from the navigation controller.
Then refering to
newViewController.refresh()
correctly updates the tableView.
I welcome any corrections to improve this, but for now my code is working! thanks for the help everyone.