I've been struggling for a few days now with passing an array from my SecondViewController to my FirstViewController using Swift.
From my research I found that segue with prepareForSegue would be a viable option but I can't seem to figure it out. What am I doing wrong?
My prepareForSegue in SecondViewController looks like this:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
var DVC: FirstViewController = segue.destinationViewController as! FirstViewController
DVC.mySeguedArray = myIncomeArray
}
My FirstViewController looks like this:
class FirstViewController: UIViewController {
@IBOutlet weak var textView: UITextView!
var myIncomeArray: [Income] = []
var mySeguedArray: [Income] = []
override func viewDidLoad() {
super.viewDidLoad()
myIncomeArray = mySeguedArray
}
Also worth mentioning is that I'm sure I'm populating the array in the SecondViewController as I'm testing it by printing out the size of the array when adding new Income objects to it. But the array in FirstViewController just returns 0 when checking it size after segue.
Edit: Added picture of storyboard StoryBoard
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'passArray'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'