Checklists can be fixed by implementing protocols.. Check the WWDC following:
https://developer.apple.com/videos/play/wwdc2015-408/
Furthermore, in regards to segues, there's a few things to note (the same applies to OSX)...
Note:
i) A segue, per definition is a transition between one one part to another (of a scene in a film or a part in music). So they're meant to be a "go-between" when it comes to view controllers...
i.e. ViewController1 <-- segue ->> ViewController2
ii) When you subclass and override prepareForSegue
you're telling your code that you want to handle the transition yourself. i.e. in a UITabviewController (or NSStabViewController), you override their default behaviours with some you want to implement of your own in the overrides
Part 1) PrepareForSegue
- Before it happens:
This is where you instantiate, configure, set up etc... your view-controllers.. If they're already set-up then you should otherwise be super-calling here.
//i.e. super.PrepareSegueForIdentifier(identifier)
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "something" {
// Do your thing here
// MARK: IFYES
} else {
prepareForSegue(segue, sender: sender)
}
}
If you have pre-preparation work for your "to be" view controller, then set it up in the first part of the "if" statement which I marked 'IFYES'. You set up things like the animations, from and to colors, sizes etc...
After this has been done, then there's another method:
performSegueWithIdentifier:
And an example I use is:
override func performSegueWithIdentifier(identifier: String, sender: AnyObject?) {
if (identifier == "yourIdentifier") {
Do something here
} else {
super.performSegueWithIdentifier(identifier, sender: sender)
}
}
This is when the segue, with the identifier of yourIdentifier
actually does something. i.e. when your viewController calls in an action or function :
func someFunction(){
self.performSegueWithIdentifier("yourIdentifier", sender: senderObjectName)
}
This is of course if you've made sure that your segue's between controllers etc... have the correct identifiers and types...