1

I am currently trying to create an iPhone calendar app. In order to make sure it syncs with the existing iPhone calendars, I am using the EKEvent toolkit.

However, the events I will be storing will have more properties than the ones EKEvent allows for- e.g., my events will not just have title, details and the few other categories that are allowed for; they will also have themes, priorities...

Thus, when I load the EKEventStore every time my calendar starts up, this information will not be contained in the EKEvents that are loaded.

How can I associate this information to the existing EKEvents so that whenever my calendar is loaded, these additional properties are also loaded?

I would use the eventIdentifier but the iPhone documentation says that "If the calendar of an event changes, its identifier most likely changes as well." If I am reading this correctly, this means that I cannot consistently use eventIdentifier to identify an event..

4

1 回答 1

0

我将使用该notes属性并设置一个您可以稍后解析的字符串。由于 EKCalendarItem 是 EKEvent 的超类,它的一些属性EKEvent继承自EKCalendarItem. (这里的文档

但是,您仍然可以在 上“设置”注释EKEvent,即使 notes 不再是 的属性EKEvent。(去搞清楚)

因此,根据您的问题,我可能会为您的每个附加(自定义)属性设置一个整数,就像这样..

在创建事件的视图控制器代码中: - 为每个自定义选项设置一个整数。(优先级、主题等)

int优先级= 0;

    EKEvent *newEvent = [EKEvent eventWithEventStore:yourEventStore];

    [newEvent setCalendar:yourCalendar];

    if (priority == 0) {
        newEvent.notes = @"0"
    }

    newEvent.title = @"YourTitle";
    newEvent.startDate = yourStartDate;
    newEvent.endDate = yourEndDate;

    [youreventStore saveEvent:newEvent span:EKSpanThisEvent commit:YES error:nil];

然后,如果您想检查/转换自定义属性,只需检查事件的注释,无论何时使用characterAtIndex或从注释中创建子字符串并将其与另一个字符串进行比较。

于 2012-11-11T22:24:13.197 回答