我尝试在 Xcode 4.6.3 下重新编写以下教程 - http://vimeo.com/29824336
但我有一个问题,在 24:00 左右我的代码没有发出警报:
-(void) scheduleLocalNotificationWithDate:(NSDate *)fireDate
{
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = fireDate;
notification.alertBody = @"Time to wake up!";
notification.soundName = @"SNSD-Oh.caf";
NSLog(@"Ring Ring Ring!");
[[UIApplication sharedApplication] scheduleLocalNotification: notification];
}
- (IBAction) alarmSetButtonTapped:(id)sender
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.timeZone = [NSTimeZone defaultTimeZone];
dateFormatter.timeStyle = NSDateFormatterShortStyle;
dateFormatter.dateStyle = NSDateFormatterShortStyle;
NSString *dateTimeString = [dateFormatter stringFromDate: dateTimePicker.date];
NSLog(@"Alarm Set Button tapped: %@", dateTimeString);
[self scheduleLocalNotificationWithDate: dateTimePicker.date];
}
我做错了什么?