Skip to content

Add completed BKBirthdayField#5

Open
jeffkibuule wants to merge 2 commits intobkook:masterfrom
jeffkibuule:birthday
Open

Add completed BKBirthdayField#5
jeffkibuule wants to merge 2 commits intobkook:masterfrom
jeffkibuule:birthday

Conversation

@jeffkibuule
Copy link
Copy Markdown

  • 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).
Comment thread BKMoneyKit/BKBirthdayField.m Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants