Reputation: 12549
I have a meeting planner app that has its own sqlite database and attaches it self to an EKEvent from the calendar framework. I'm using the event identifier as a foreign key for my meeting data. The problem resides when a user changes the event's calendar in the calendar application. The identifier changes and I got no way of knowing that it changed since it was made outside my app. Please let me know if anyone has any ideas
Upvotes: 0
Views: 1168
Reputation: 158
I'm facing with this problem right now, trying to keep synced EventStore with the internal DB on my app, my solution is to make a mapping between EKEvents and events inside the app, if I found matching it's ok but all the events that don't match with EKEvents will be deleted, and all the EKEvents without match will be added, doing this also the EKEvents that are just being modified will be added during the sync.
Upvotes: 0
Reputation: 33592
The documentation warns that "If the calendar of an event changes, its identifier most likely changes as well."
Another gotcha is that all instances of a repeating event have the same identifier; -[EKEventStore eventWithIdentifier:]
seems to return the first instance. (I've even seen events with a nil identifier; I can't remember what the exact cause is.)
If -eventWithIdentifier:
returns a non-repeating event, then you're probably good to go. Otherwise, the easiest way around both of these is probably to search all calendars for events at around the same time and use a heuristic to determine the best match, or ask the user to pick the corresponding event if none of the matches are good enough.
You might also want to check what Google Calendar does when you edit a single instance of a repeating event (it might create an event with a new identifier and add a "hole" in the original event's repeat information, which may break your heuristic).
Upvotes: 1
Reputation: 173
as of iOS 5.0 there is no way to uniquely identifying an event with certainty
Upvotes: 1