// 代碼如下,是轉載別處的,別處也是轉載其他地方的,就未寫明出處了。發現在xcode 5.1 的模擬器上可以測試,在xcode 6 上的模擬器就出不來,浪費了我不少的時間。
UILocalNotification *notification=[[UILocalNotification alloc] init];
if (notification!=nil) {
NSLog(@">> support local notification");
NSDate *now=[NSDate new];
notification.fireDate=[now dateByAddingTimeInterval:3];
notification.timeZone=[NSTimeZone defaultTimeZone];
notification.alertBody=@"該去吃晚飯了!";
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}