In my app a user can select whether or not they are under 18 or over 18 years of age. The user enters their Date of Birth using a Date Picker. I need to make a function that will compare the current date in MM/DD/YYYY format to the DatePicker date to see if the user's entered age is over 18.
My current function for setting the DatePicker text to the associated textfield is:
func updatePicker() {
var dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MM/dd/yyyy"
dob.text = dateFormatter.stringFromDate(datePickerView.date)
}
When the user tries to go the next page, the form is validated which is when I need to compare the dates and display the alert if they're under 18.
Just not sure where to start with date string evaluation.