I'm building an exercise app. I have an array of exercises in my TableViewController, with each cell displaying a different exercise. The cells segue to a UIViewController. Within the UIViewController I would now like a user to be able to skip to the next exercise without having to go back to the TableViewController.
How can I refresh my ViewController containing the new data of the next exercise? (Similar to the reloadData method when constructing tables?)
I'm getting the next exercise in the array, but my page isn't refreshing. My code:
var exercise: Exercise?
var exerciseList: [Exercise]!
// toolbar item button pressed:
@IBAction func nextExercise(sender: UIBarButtonItem) {
if let currentIndex = exerciseSet.indexOf(exercise!) {
let nextIndex = currentIndex + 1
let nextExercise = exerciseList[nextIndex]
reloadData(nextExercise)
}
}
private func reloadData(displayedExercise: Exercise){
exercise = displayedExercise
self.view.setNeedsDisplay()
}
Thanks!