I'm grabbing the current date and comparing it to a predefined date, however I'm having an issue where the string is different sometimes. My code:
NSDate *todaysDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSString *dateToday = [dateFormatter stringFromDate:todaysDate];
NSLog(@"%@", dateToday);
Sometimes I'll get 'Dec 30, 2013' - sometimes 'Dec 30 2013' (no comma) and sometimes '30 Dec 2013'. I cannot see why this would happen.
Any thoughts?
EDIT: Responding to questions asked. I'm simply trying to see if the current date is the same as a predefined date, or if it's beyond that date. My code for this is:
if ([dateToday isEqual: @"30 Dec 2013"]) {
//It's the day of the event, run the day view
[self performSegueWithIdentifier:@"mainToDay" sender:self];
} else if ([todaysDate timeIntervalSinceDate:postEventDate] > 0) {
//It's after the event, run the post event screen
[self performSegueWithIdentifier:@"mainToPost" sender:self];
}
I was simply using the log to see what was returned then emulating it. I didn't realise it would change. :)
Cheers.