Instance Method

predicateForEvents(withStart:end:calendars:)

Creates and returns a predicate for finding events in the event store that fall within a given date range.

Declaration

func predicateForEvents(withStart startDate: Date, end endDate: Date, calendars: [EKCalendar]?) -> NSPredicate

Parameters

startDate

The start date of the range of events fetched.

endDate

The end date of the range of events fetched.

calendars

The calendars to search, as an array of EKCalendar objects. Passing nil indicates to search all calendars.

Return Value

A simple query predicate that matches events within the specified date range.

Discussion

Use this method to create a predicate for use with events(matching:) or enumerateEvents(matching:using:). The events returned using this predicate are in the default time zone. For performance reasons, this method matches only those events within a four year time span. If the date range between startDate and endDate is greater than four years, it is shortened to the first four years.

See Also

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software