NSDateFormatter iOS6 issue
- by Angad Manchanda
I have written a code for UIButton press to decrement date. The present date is shown in a UILabel text property and it changes to the previous date when the button is pressed. The following code works perfectly fine for iOS5 but doesn't work with iOS6. With iOS6, it gives the output as Dec 31, 1999 or null.
- (IBAction)showPrevDate:(id)sender
{
NSString *dateForDecrement = _showDateLbl.text;
[dateFormatter setDateFormat:@"MMM d, yyyy (EEE)"];
NSDate *dateObjectForDecrement = [dateFormatter dateFromString:dateForDecrement];
int subtractDays = 1;
dateAfterDecrement=[dateObjectForDecrement dateByAddingTimeInterval:-(24*60*60 * subtractDays)];
_showDateLbl.text = [NSString stringWithFormat:@"%@", [dateFormatter stringFromDate:dateAfterDecrement]];
}
Can anybody verify this, or tell me if its's a bug in iOS6 ?
Thanks guys.