I have three arrays that have the data to populate the complication timeline with entries.
When I scroll through time travel, the complication does not change so I know I must be doing something wrong.
func getTimelineEntriesForComplication(complication: CLKComplication, afterDate date: NSDate, limit: Int, withHandler handler: (([CLKComplicationTimelineEntry]?) -> Void)) {
for headerObject in headerArray! {
for body1Object in body1Array! {
for body2Object in body2Array! {
let headerTextProvider = CLKSimpleTextProvider(text: headerObject as! String)
let body1TextProvider = CLKSimpleTextProvider(text: body1Object as! String)
let body2TextProvider = CLKRelativeDateTextProvider(date: body2Object as! NSDate, style: .Offset, units: .Day)
print("HeaderTextProvider: \(headerTextProvider)")
print("Body1TextProvider: \(body1TextProvider)")
print("Body2TextProvider: \(body2TextProvider)")
let template = CLKComplicationTemplateModularLargeStandardBody()
template.headerTextProvider = headerTextProvider
template.body1TextProvider = body1TextProvider
template.body2TextProvider = body2TextProvider
let timelineEntry = CLKComplicationTimelineEntry(date: body2Object as! NSDate, complicationTemplate: template)
entries.append(timelineEntry)
print("TimeEnt: \(entries)")
print("TimeEntCount: \(entries.count)")
}
}
}
handler(entries)
}
My thinking:
- Loop through the three arrays
- Set the template with the results of the array loops
- Set the timeline entry with the date of the object in
body2Array
The output on my console is:
HeaderTextProvider: <CLKSimpleTextProvider: 0x78e3f800>
Body1TextProvider: <CLKSimpleTextProvider: 0x78e4eb30>
Body2TextProvider: <CLKRelativeDateTextProvider: 0x78e4f050>
TimeEnt: [<CLKComplicationTimelineEntry: 0x78e4edd0> date = 2016-03-21 05:00:00 +0000, template = <CLKComplicationTemplateModularLargeStandardBody: 0x78e4edf0>, animationGroup = (null), <CLKComplicationTimelineEntry: 0x78e4f520> date = 2016-10-01 17:00:00 +0000, template = <CLKComplicationTemplateModularLargeStandardBody: 0x78e4f540>, animationGroup = (null)]
TimeEntCount: 2