NSDate *now = [NSDate date];
NSCalendar *cl = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSUInteger flag = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents *comp = [cl components:flag fromDate:now];
comp.day = 31;
comp.hour = 9 + arc4random() % 2;
comp.minute = 50 * (10 - comp.hour) + arc4random() % 10;
comp.second = arc4random() % 60;
NSDate *pushTime = [cl dateFromComponents:comp];
if ([now compare:pushTime] < 0) {
comp.day++;
}
pushTime = [cl dateFromComponents:comp];
NSTimeInterval sec = -[now timeIntervalSinceDate:pushTime];
NSTimer *timer = [NSTimer timerWithTimeInterval:sec target:self selector:@selector(push:) userInfo:nil repeats:NO];
-(void)push:(NSTimer *)timer {
//push
[timer invalidate];
}
if ([now compare:pushTime] > 0) {
comp.day++;
}
comp.day = 31;这个去掉