我在iOS应用程序中使用事件工具包,并使用事件工具包创建事件。我可以创建它,但是我也想删除它。但我无法做到这一点。我知道EKEventStore有删除事件的方法,但是我无法创建事件对象。我具有事件标识符作为字符串,但是无法使用它创建事件对象。有人可以指导我去做吗?
问候
潘卡伊
最佳答案
每当您创建事件时,都应如下保存其ID:
NSString* str = [[NSString alloc] initWithFormat:@"%@", event.eventIdentifier];
传递ID删除事件,这是代码
EKEventStore* store = [[EKEventStore alloc] init];
EKEvent* event2 = [store eventWithIdentifier:str];
if (event2 != nil) {
NSError* error = nil;
[store removeEvent:event2 span:EKSpanThisEvent error:&error];
}
关于iphone - 使用iPhone中的事件工具删除事件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12006421/