Jump to content
Welcome to InsanelyMac Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

  • Announcements

    • Allan

      Forum Rules   04/13/2018

      Hello folks! As some things are being fixed, we'll keep you updated. Per hour the Forum Rules don't have a dedicated "Tab", so here is the place that we have our Rules back. New Users Lounge > [READ] - InsanelyMac Forum Rules - The InsanelyMac Staff Team. 
Sign in to follow this  
Larry_The_Great

Please Help with simple code

2 posts in this topic

Recommended 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 {
  2.  
  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. }
  17.  
  18. if (!switchoutlet.on) {
  19. //remove event
  20. }
  21.  
  22.  
  23. }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×