Created
March 30, 2016 06:41
-
-
Save groue/f4dd0bbe05e77348d6482eda3d39d2c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Navigation | |
extension PersonsViewController { | |
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | |
if segue.identifier == "NewPerson" { | |
let navigationController = segue.destinationViewController as! UINavigationController | |
let controller = navigationController.viewControllers.first as! PersonEditionViewController | |
controller.title = "New Person" | |
controller.person = Person(name: "", score: 0) | |
} | |
} | |
@IBAction func addPerson(sender: AnyObject?) { | |
performSegueWithIdentifier("NewPerson", sender: sender) | |
} | |
@IBAction func cancelPersonEdition(segue: UIStoryboardSegue) { | |
// Person creation: Cancel button was tapped | |
} | |
@IBAction func commitPersonEdition(segue: UIStoryboardSegue) { | |
// Person creation: Done button was tapped | |
let controller = segue.sourceViewController as! PersonEditionViewController | |
controller.applyChanges() | |
// Avoid saving when name is empty | |
if !controller.person.name.isEmpty { | |
try! controller.person.save(dbQueue) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment