Instance Method

getTimelineEntries(for:before:limit:withHandler:)

Retrieves past timeline entries for the complication.

Declaration

optional func getTimelineEntries(for complication: CLKComplication, before date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void)

Parameters

complication

The complication tied to the request. Use the complication family information in this object to determine which set of templates are valid.

date

The end date for providing past entries. The dates for your timeline entries should occur before this date and be as close to the date as possible.

limit

The maximum number of entries to provide.

handler

The handler to execute with the past timeline data. This block has no return value and takes the following parameter:

entries

An array of CLKComplicationTimelineEntry objects representing the past data. The number of entries in the array must be less than or equal to the value in the limit parameter. If you specify nil, ClockKit doesn’t try to extend the timeline further.

Discussion

Only implement this method if your app supports Time Travel on watchOS 4 or earlier.

Use this method to build an array of timeline entries with your app’s past data. Each timeline entry contains the data and the date at which that data is valid. Don’t provide entries with dates after the one in the date parameter, and limit the number of entries you create to the value in the limit parameter.

The array you return must start in the past and extend forward into time, ending no later than the date specified in the date parameter. Each successive entry in the array must come after the one before it. Entries must be greater than one minute apart. If two entries are less than one minute apart, ClockKit discards one of the entries.

Don’t include the current entry in your array. That entry is retrieved separately using the getCurrentTimelineEntry(for:withHandler:) method.

If you don’t implement this method, ClockKit doesn’t try to add earlier entries to the timeline.