Skip to content

Commit

Permalink
Fixed 'Calendar Date Issue #2', posted by girishnair12345: "date cann…
Browse files Browse the repository at this point in the history
…ot be nil..."
  • Loading branch information
maximbilan committed Jul 11, 2014
1 parent 1370f9e commit 34563c3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ios_calendar/Sources/CalendarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,13 @@ - (void)setMode:(NSInteger)m

- (void)setCurrentDate:(NSDate *)currentDate
{
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:currentDate];
currentDay = [components day];
currentMonth = [components month];
currentYear = [components year];
if (currentDate) {
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:currentDate];
currentDay = [components day];
currentMonth = [components month];
currentYear = [components year];
}
}

- (NSDate *)currentDate
Expand Down

0 comments on commit 34563c3

Please sign in to comment.