闹钟主要实现代码
UILocalNotification *notification=[[UILocalNotification alloc] init];
????if (notification!=nil)?
????{???
????????notification.repeatInterval=NSDayCalendarUnit;
????????NSDate *now1=[NSDate new];
????????notification.fireDate=[now1 dateByAddingTimeInterval:hm];
????????notification.timeZone=[NSTimeZone defaultTimeZone];
????????notification.soundName = @"ping.caf";
????????notification.alertBody = [NSString stringWithFormat:NSLocalizedString(@"你设置的时间是:%i : %i .",nil),htime1,mtime1];
?????? [[UIApplication sharedApplication]?? scheduleLocalNotification:notification];
????????}
这个是建立后台消息对象
如果是程序开这的可以用UIApplication的代理方法
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
来实现闹钟的响铃