简体   繁体   中英

Set EKAlarm in iphone app

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.

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM