我想在每天上午 8:00 连续 30 天安排 UILocalNotificaion,并且我想仅使用一个 UILocationNotification 实例来实现该功能。这是我安排本地通知的代码。
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"HH:mm"];
NSDate *date = [[NSDate alloc] init];
date = [formatter dateFromString:@"08:00"];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = date;
localNotification.timeZone=[NSTimeZone defaultTimeZone];
localNotification.alertBody = @"You just received a local notification";
localNotification.alertAction = @"View Details";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.repeatInterval = NSDayCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[formatter release];
[date release];
它将在上午 08:00 永远触发每日通知,但我只想连续 30 天收到通知。最简单的解决方案是触发 30 个 UILocalNotifications,但我想用 1 个 UILocalNotification 实例来做到这一点。我怎样才能做到这一点?请帮忙。