You cannot directly exit because the table view is in a different scene (view controller), but you can access the table view as soon as you have a reference to the UITableViewController instance. There are several ways to do this.
First you can use the childViewControllers property of your subclass of UIViewController . If you know that there is only one child, then you can access it directly, otherwise you need to determine which one is correct, say, by cycling through the array.
let myTableViewController = self.childViewControllers[0] as! UITableViewController let theTableView = myTableViewController.tableView
The second option is to access the UITableViewController during the implementation of segue. If you click on the built-in segue in your storyboard, you can give it an identifier, like in any other segment. Then you can implement prepareForSegue and grab a built-in instance of the UITableViewController -
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { if (segue.identifier == "tableviewEmbed") { let myTableViewController = segue.destinationViewController as! UITableViewController let theTableView = myTableViewController.tableView } }
Personally, I prefer this second approach, because I think it is βcleanerβ
source share