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- eg, 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..
I would use the notes
property and set a string which you can parse later. Since EKCalendarItem is EKEvent's superclass some of the properties of EKEvent
are inherited from EKCalendarItem
. ( documentation here )
However, you can still 'set' notes on an EKEvent
, even though notes is not a property of EKEvent
anymore. (go figure)
So, from your question, I might set an integer for each of your additional (custom) properties, like so..
In the view controller code that creates the event: - set an integer for each of you custom options. (priority, theme, etc.)
int priority = 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];
Then if you want to check/convert the custom property, just check the notes of the event whenever you fetch them either using characterAtIndex
or make a subString from the notes and compare that to another string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.