Add completed BKBirthdayField#5
Conversation
jeffkibuule
commented
Mar 23, 2015
- Add finished implementation of BKBirthdayField for (MM/DD/YYYY) format
- Updated example app with BKBirthdayField and associated label
- Sample app will say "Invalid for non-leap year" if you type in month (2) and day (29) for years that are not a leap year.
- Added UITapGestureRecognizer so you can see associated label for BKBirthdayField (UIScrollView probably better, but code to account for keyboard is distracting from purpose of demo).
* Add finished implementation of BKBirthdayField for (MM/DD/YYYY) format * Updated example app with BKBirthdayField and associated label * Sample app will say "Invalid for non-leap year" if you type in month (2) and day (29) for years that are not a leap year. * Added UITapGestureRecognizer so you can see associated label for BKBirthdayField (UIScrollView probably better, but code to account for keyboard is distracting from purpose of demo).
There was a problem hiding this comment.
How about using NSCalendar for this validation check?
Please refer to below URL. You can get last date of month by using NSCalendar.
http://stackoverflow.com/questions/24475260/getting-the-last-day-of-the-month-in-objective-c
There was a problem hiding this comment.
Hello @bkook:
Problem with trying to use NSDateComponents is that with the MM / DD / YYYY format, the year hasn't been typed in yet so I can't use NSDateComponents to do the actual calculations. And generally it would work, except for leap months.
I also feel weird instantiating NSDate objects and using NSCalendar to do pretty heavy math when the current solution gets the correct date in just 3 operations (1 switch and 2 integer comparisons).
I'll move that code to a separate method so it reads cleaner.