Age Confirmation question

Hi, I am wondering how you make an age verifier in storyboards and swift? Pretty new to xcode. If someone could explain how I set my basic age (im assuming a bool) so that anyone that is 18 or over can proceed but anyone younger cannot.


Thank you

Replies

You would have a text field where you enter the age

@IBOutlet var ageField: UITextField!
var isUnder18: Bool = true     // By default, we take the safe side

Then you test

if let ageValue = Int(ageField.text!) {
     isUnder18 = ageValue >= 18
} else {
     isUnder18 = true
     // alert to ask for age
}