eliu2016 / Swap

Repository for iOS Application - Swap
2 stars 1 forks source link

Birthday #58

Closed MichealSBingham closed 7 years ago

MichealSBingham commented 7 years ago

Check that the user is > 13

MichealSBingham commented 7 years ago
  extension Date {
var age: Int {
    return Calendar.current.dateComponents([.year], from: self, to: Date()).year!
}

}

   @IBAction func didPressContinue(_ sender: Any) {

    guard datePicker.date.age >= 13 else{

        UIAlertView(title: "Sorry",
                    message: "You must be at least 13 years old to use Swap.",
                    delegate: nil,
                    cancelButtonTitle: "Ok").show()

        return

    }
   // save birthday
    self.performSegue(withIdentifier: "toEmailController", sender: nil)

}