I am trying to call a method on this time : 00:01 AM here is my code but I can’t find the problem why this code does not call my method.
- (BOOL)date:(NSDate *)date hour:(NSInteger)h minute:(NSInteger)m {
NSCalendar *calendar = [[NSCalendar alloc]initWithCalendarIdentifier:currentCalendar];
NSDateComponents *componets = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit )fromDate:[NSDate date]];
if ([componets hour ] == h && [componets minute] == m) {
return YES;
}
return NO;
}
- (void)updateNewDate {
if ([self date:[NSDate date] hour:4 minute:49]) {
label.text = @"oyooy";
}
}
- (void)viewDidLoad {
[self updateNewDate];
}
If you have any other methods please tell me .
Actually your code works fine but it needs refreshing … for example you can use
NSTimerto refresh your method :