ClockKit CLKComplicationDataSource缺少向后事件 [英] ClockKit CLKComplicationDataSource missing backward events

查看:135
本文介绍了ClockKit CLKComplicationDataSource缺少向后事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个具有并发症支持功能的测试应用

I write a test app with complications support

由于某种原因,钟面仅显示1-2个后退事件,但我可以在日志中看到当前日期之前的10-15个事件. 当我为前向事件返回一个空数组时,我所有的后向事件都开始在钟面上显示.

For some reason clock faces presenting only 1-2 backward events, but I can see in logs 10-15 events before current date. And when I return an empty array for forward events all my backward events start showing in clock face.

这是我的职责

func getTimelineEntriesForComplication(complication: CLKComplication, beforeDate date: NSDate, limit: Int, withHandler handler: (([CLKComplicationTimelineEntry]?) -> Void)) {

    var entries: [CLKComplicationTimelineEntry] = []

    let events = self.events.filter { (event: CEEvent) -> Bool in
        return date.compare(event.startDate) == .OrderedDescending
    }

    var lastDate = date.midnightDate

    for event in events {
        let entry = CLKComplicationTimelineEntry(date: lastDate, complicationTemplate: event.getComplicationTemplate(complication.family))

        if let endDate = event.endDate {
            lastDate = endDate
        } else {
            lastDate = event.startDate
        }

        entries.append(entry)

        if entries.count >= limit {
            break
        }
    }

    handler(entries)
}

P.S.我知道'limit'参数,它总是大于数组的计数

P.S. I know about 'limit' parameter and it's always greater than my array's count

P.P.S.对不起我的英语:)

P.P.S. Sorry about my English :)

推荐答案

我已经看到watchOS 2.0.1的相同行为,即时间最初倒退仅显示两个较早的条目,即使要求数据源并返回100个条目.

I've seen that identical behavior for watchOS 2.0.1 where time travel backwards initially only shows two earlier entries, even though the datasource was asked for and returned 100 entries.

发射后约15分钟,开始出现更多条目以进行倒退旅行.发射大约30分钟后,所有100个以前的条目都出现了.

About 15 minutes after launch, more entries started appearing for backwards time travel. About 30 minutes after launch, all 100 prior entries were present.

这不是我计划的任何更新,因为并发症的更新间隔为24小时.

This was not due to any update I scheduled, as my complication's update interval is 24 hours.

看来,复杂服务器会优先考虑添加前向条目,但会延迟所有后向时间行进条目来填充缓存.您必须问苹果是优化还是错误.

It appears that the complication server prioritizes adding the forward entries, but defers populating the cache with all the backward time travel entries. You'd have to ask Apple whether it's an optimization or a bug.

我不知道这是否是巧合,但我的时间轴条目间隔15分钟.也许当并发症服务器更新并发症以显示新的时间线条目时,它还会添加更多批处理的较早条目吗?

这篇关于ClockKit CLKComplicationDataSource缺少向后事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆