Inspite of datecomponents being what I set to (i.e, 12 PM) and the date object being correct -5:30 hours from my time zone IST), when I try and set the date on the picker using setDate:Animated: method, the time remains to current time (ie, the time the view controller containing the picker appears). Can someone explain what could be wrong?
- (void)viewDidLoad {
[super viewDidLoad];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSData *hAndMData = [[NSUbiquitousKeyValueStore defaultStore] objectForKey:@"AddReminder"];
NSError *error;
hoursAndMinutes = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSDateComponents class] fromData:hAndMData error:&error];
if (error!=nil) {
NSLog(@"error in unarchiving date componenet in settingsVC: %@",error);
}
else
{
dateForNotification = [[NSCalendar currentCalendar] dateFromComponents:hoursAndMinutes];
}
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:YES];
[reminderCell.addReminderTVCTimePicker setDate:dateForNotification animated:YES];
}
Thanks Neerav