NSDateFormatter iOS6 issue

Posted by Angad Manchanda on Stack Overflow See other posts from Stack Overflow or by Angad Manchanda
Published on 2012-10-28T10:40:44Z Indexed on 2012/10/28 11:01 UTC
Read the original article Hit count: 241

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about ios

Related posts about ios6