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 に答える