0

我想在我的 AppDelegate 上设置多个本地通知,就像这段代码中显示的一样。这可能吗?

另外,我已经在下面的代码中设置了这个通知,但是我怎样才能从周一到周五重复呢?

这是我的代码:

AppDelegate.m

- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
 Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
 If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
 */

NSCalendar *gregCalendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];

NSDateComponents *dateComponent = [gregCalendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit fromDate:[NSDate date]];

[dateComponent setWeekday:5];
[dateComponent setHour:11];
[dateComponent setMinute:26];


UIDatePicker *dd = [[UIDatePicker alloc]init];
[dd setDate:[gregCalendar dateFromComponents:dateComponent]];



UILocalNotification *notification = [[UILocalNotification alloc]init];
[notification setAlertBody:@"Let the Music Play"];
[notification setFireDate:dd.date];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
[application setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];

}

谢谢!

4

1 回答 1

0

将通知的 repeatInterval 属性设置为 NSWeekdayCalendarUnit。

于 2013-02-28T19:03:04.200 回答