It’s possible for a user’s Calendar database to be modified by another process or application while your application is running. If your application fetches calendar events, you should register to be notified about changes to the Calendar database. By doing so, you ensure that the calendar information you display to the user is current.
An EKEventStore
object posts an EKEventStoreChangedNotification
notification whenever it detects changes to the Calendar database. Register for this notification if your application handles event data.
The following code registers for the EKEventStoreChangedNotification
notification:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(storeChanged:) |
name:EKEventStoreChangedNotification object:eventStore]; |
When you receive an EKEventStoreChangedNotification
notification, it’s possible that changes have been made to EKEvent
objects you fetched and retained. The effect of these changes depends on whether an event was added, modified, or deleted.
If an event was added, it does not affect any of your retained events, but the added event may fall within the date range of events you are displaying to the user.
If an event was modified or deleted, properties of EKEvent
objects representing that event become out-of-date.
Because your local data is often invalidated or incomplete when a change occurs in the Calendar database, you should release and refetch your current date range of events whenever you receive an EKEventStoreChangedNotification
notification. If you are currently modifying an event and you do not want to refetch it unless it is absolutely necessary to do so, you can call the refresh
method on the event. If the method returns YES
, you can continue to use the event; otherwise, you need to release and refetch it.
Events being modified in an event view controller are updated automatically when a change occurs in the Calendar database.
Last updated: 2010-08-03