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

查看:27
本文介绍了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)
}

附言我知道 '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天全站免登陆