Jump to content

Please Help with simple code

xcode ios objective-c calendar

  • Please log in to reply
1 reply to this topic



    InsanelyMac Protégé

  • Members
  • Pip
  • 7 posts

Dear InsanelyMac forum

I have been all across the internet trying to find a solution for my simple coding problem. But everywhere I go I cannot find anything of use and no one will reply to my posts. I am a novice programmer and it would be greatly appreciated if someone could spare a few moments to either give me some sample code to fix my problem or point me to somewhere else that can help me.

Heres the situation: I'm adding a simple feature in my ios xcode ios app that has a UISwitch. When the UISwitch is on an event is created (this part works fine). But when I turn the UISwitch off I cannot find a way to remove the event. Can someone please tell me what code I need to remove the event. 


  1. - (IBAction)switchon:(id)sender {
  3. if (switchoutlet.on) {
  4. EKEventStore *store = [[EKEventStore alloc] init];
  5. [store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
  6. if (!granted) { return; }
  7. EKEvent *event = [EKEvent eventWithEventStore:store];
  8. event.title = @"Event A";
  9. event.startDate = [NSDate dateWithTimeIntervalSince1970:1406948400]; //today
  10. event.endDate = [event.startDate dateByAddingTimeInterval:60*60]; //set 1 hour meeting
  11. [event setCalendar:[store defaultCalendarForNewEvents]];
  12. NSError *err = nil;
  13. [store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
  14. NSString *savedEventId = event.eventIdentifier; //this is so you can access this event later
  15. }];
  16. }
  18. if (!switchoutlet.on) {
  19. //remove event
  20. }
  23. }



    InsanelyMac Geek

  • Members
  • PipPipPip
  • 172 posts

Don't know anything about class EKEventStore ,  


see C - Scope Rules.

Also tagged with one or more of these keywords: xcode, ios, objective-c, calendar

  Topic Stats Last Post Info

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2017 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy