I'm trying to select and set an instance variable that is part of another UIViewController, however, I don't know how to select another ViewController and access its contents without using a segue.
Whenever a user checks off a task, a percentage of tasks that are complete should be calculated and another view controller's instance variable should be set.
I realize I'm currently instantiating a new view controller instead of selecting the one I already have on the storyboard. I'm using a third party sidebar menu that resides behind my main view, although it really exists as a separate Scene/ViewController. It should be noted that this sidebar menu doesn't use a segue reveal itself. Is there any method to select another view controller and access it's instance variables?
@IBAction func checkOffTask(sender: UIButton) {
// Select sidebar view controller
let sidebarViewController = self.storyboard?.instantiateViewControllerWithIdentifier("sideBarScene") as! SideBarViewController
// Calculate percentage of completed tasks
// Select the count of all tasks
let allTasksCount = Float(firstDataSource.count + secondDataSource.count)
// Select the count of all completed tasks
let completedTasksCount = Float(secondDataSource.count)
// Divide the two to get a percentage
var completedTaskPercentage = completedTasksCount / allTasksCount
sidebarViewController.completedTaskPercentageTemporary = String(stringInterpolationSegment: completedTaskPercentage)
println(sidebarViewController)
println(sidebarViewController.completedTaskPercentageTemporary)
}