setDate method of UIDatePickerView in compact mode (time only) doesn't update time. Only shows current time.

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

Answered by ace.neerav in 726110022

Solved! I wasn't assigning the cell (to reminderCell), returned from the dequeReusableCell method inside cellForRow datasource. Thus I was calling the setDate on a nil object.

Accepted Answer

Solved! I wasn't assigning the cell (to reminderCell), returned from the dequeReusableCell method inside cellForRow datasource. Thus I was calling the setDate on a nil object.