Set EKAlarm in iphone app

倖福魔咒の 提交于 2019-12-08 09:18:17

问题


I m trying to set alarm from app with my audio file but getting lots of messages like

Use of undeclared identifier EKAlarm

Unknown receiver EKEvent did you mean UIEvent

Member reference base type 'int" is not a structure or union

 @property (retain, nonatomic) EKAlarm *alarm;

 @synthesize alarm;

-(void) AlarmAction:(id)sender{

EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:-300];


[EKEvent addAlarm:alarm];
alarm.soundName =
  }

Thanks for help.


回答1:


Have you added the EventKit framework? It must be added under Link Binary With Libraries under the Build Phases tab of your project properties.

====== EDIT:

You should be using UILocalNotification (Class Reference). You should:

  • Create an instance of UILocalNotification,
  • Set the fireDate property to the time you would like the alarm to fire,
  • If desired, set the repeatInterval to some NSCalendarUnit (see here),
  • Set the soundName property to the file name of the audio file you wish to play,
  • Finally, schedule it with [[UIApplication sharedApplication] scheduleLocalNotification: myNotification];


来源:https://stackoverflow.com/questions/14775954/set-ekalarm-in-iphone-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!