NSCalendar *gCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *oldDate = [NSDate date];
unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay;
NSDateComponents *comps = [gCalendar components:unitFlags fromDate:oldDate];
comps.hour = 23;
comps.minute = 59;
comps.second = 59;
comps.calendar = gCalendar;
NSDate *newDate = [gCalendar dateFromComponents:comps];
When I run the above snippet, the variable newDate is of type __NSTaggedDate. This ultimately causes problems because __NSTaggedDate cannot subsequently be serialized by JSON.
I am trying to create an NSDate that has the last second time of today.
I am on Xcode 6.4, and iOS 8.4 is running on my phone. This happened both on the simulator and on the iPhone6.
source
share