Deleting an EKEvent from device's calendar using its identifier

冷暖自知 提交于 2019-12-04 19:14:38

For deleting use this code

-(void)removeMeWithIndex:(int)index
{
    EKEvent* eventToRemove = [eventStore eventWithIdentifier:[arrayofEventId objectAtIndex:index]];

    if (eventToRemove != nil) {
        NSError* error = nil;
        [eventStore removeEvent:eventToRemove span:EKSpanThisEvent error:&error];
    }
}

-(IBAction)remove
{
  [self removeMeWithIndex:0];
}

I have updated my code to check if id exists or not as

-(void)removeMeWithIndex:(int)index
{
    NSLog(@"id is %@",[[NSUserDefaults standardUserDefaults] valueForKey:@"id"]);
    EKEvent* eventToRemove = [eventStore eventWithIdentifier:[[NSUserDefaults standardUserDefaults] valueForKey:@"id"]];

    if (eventToRemove != nil) {
        NSError* error = nil;
        [eventStore removeEvent:eventToRemove span:EKSpanThisEvent error:&error];
    }
}

output after deletion is ...

2013-06-26 18:51:43.999 CARL[674:907] id is 7AFE7AC2-111A-446F-86E6-8D69AD38F1AF:CA946E83-BE08-44AB-8834-06E1E4BFF7E8

your id is something like this ?

After creation of event check in calendar app in device.

After deleting event completion screenshot is :--

Here you can get sample project.

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