As your comments say, if you want changes in minutes to change the value of label.text
you need to do the following:
1st: get the current time:
NSDate *date = [NSDate date]; NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *dateComponents = [calendar components:NSHourCalendarUnit fromDate:date];
and set label.text = CURRENTHOUR_AND_YOURMINNUTS ;
and then refresh the shortcut the next minute, for example:
first, you can check after 60 - nowSeconds [self performSelector: @selector (refreshLabel) withObject: nil afterDelay: (60 - dateComponents.minute)];
- (void)refreshLabel { //refresh the label.text on the main thread dispatch_async(dispatch_get_main_queue(),^{ label.text = CURRENT_HOUR_AND_MINUTES; }); // check every 60s [self performSelector:@selector(refreshLabel) withObject:nil afterDelay:60]; }
It will be checked every minute, therefore more effective the answers above.
When refreshLabel is called, it means the minutes are changed
source share