使用iPhone中的事件工具删除事件 [英] Deleting an event using Event Kit in iPhone

查看:142
本文介绍了使用iPhone中的事件工具删除事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在iOS应用程序中使用事件工具包,并使用事件工具包创建事件.我可以创建它,但是我也想删除它.但我无法做到这一点.我知道EKEventStore有删除事件的方法,但是我无法创建事件对象.我有事件标识符作为字符串,但是无法使用它创建事件对象.有人可以指导我去做吗?

I am using Event Kit in my iOS application and creating a event using Event Kit. I am able to create it but I want to give the ability to delete also. But I am not able to do that. I know there is a method for EKEventStore to delete event but I am not able to make event object. I have event identifier as a string but I am not able to create an event object using it. Can someone please guide me to do it?

问候 潘卡(Pankaj)

Regards Pankaj

推荐答案

创建事件时,请按以下方式保存其ID:

When ever you are creating an event save its id like this:

NSString* str = [[NSString alloc] initWithFormat:@"%@", event.eventIdentifier];

传递ID删除事件,这是代码

pass the id to delete the event, here is code

EKEventStore* store = [[EKEventStore alloc] init];
    EKEvent* event2 = [store eventWithIdentifier:str];
    if (event2 != nil) {  
        NSError* error = nil;
        [store removeEvent:event2 span:EKSpanThisEvent error:&error];
    } 

这篇关于使用iPhone中的事件工具删除事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆