I'm trying to get the current time and the current day of the week (i.e. Monday, Tuesday, etc.). I'm using the code straight from the Apple Documentation:
When I insert this code into my RootViewController's viewDidLoad method along with a couple of NSLog statements to see what's going on, it crashes my previously-working app.
Anybody have any idea what I'm doing wrong here?
Code:
NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *weekdayComponents = [gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit) fromDate:today];
NSInteger day = [weekdayComponents day];
NSInteger weekday = [weekdayComponents weekday];
When I insert this code into my RootViewController's viewDidLoad method along with a couple of NSLog statements to see what's going on, it crashes my previously-working app.
Anybody have any idea what I'm doing wrong here?