I know that you can pass information between two view controllers if they are connected by a segue using
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        guard let destinationViewController = segue.destinationViewController as?  searchTermViewController else { return }
        destinationViewController.courseCodes = selectedCourses
    }
}
The above code gives an error if there is no segue because of the .destinationViewController. How do i pass information between to arbitrary view controllers without having to set up a global variable?
 
     
    