4
我正在使用Xcode 4.3.2,如何在每天早上6点设置本地通知“dateToFire”?xcode - 按时间安排本地通知(每天早上6点)
-(void)notification
{
UILocalNotification *localNotification = [[[UILocalNotification alloc] init] autorelease];
if (!localNotification)
return;
// Current date
NSDate *date = [NSDate date];
NSDate *dateToFire = //Everyday: 6AM;
// Set the fire date/time
[localNotification setFireDate:dateToFire];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
[localNotification setAlertBody:@"Notification" ];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self notification];
}
感谢您的快速回复,但它有一些错误。 1.未找到class method'+ calendar'(返回类型默认为'id')2.使用未声明的标识符'NSMinuteCalendarComponents'。 – shebi 2012-04-22 08:38:47
NSMinuteCalendarComponents是NSMinuteCalendarUnit,对不起) – 2012-04-22 08:41:08
和日历应该是currentCalendar) – 2012-04-22 08:41:30