apple-watch-complication

Call ExtensionDelegate to create/refresh data for Complication

青春壹個敷衍的年華 提交于 2019-12-17 21:06:07
问题 All my data creation is done in the ExtensionDelegate.swift . The problem is ExtensionDelegate.swift doesn't get called before the function getCurrentTimelineEntryForComplication in my ComplicationController.swift . Any ideas? Here is my code and details: So my array extEvnts is empty in my ComplicationController.swift : func getCurrentTimelineEntryForComplication(complication: CLKComplication, withHandler handler: ((CLKComplicationTimelineEntry?) -> Void)) { let extEvnts = ExtensionDelegate

What is the flow for updating complication data for Apple Watch?

别来无恙 提交于 2019-12-17 17:32:12
问题 I've been following a lot of tutorials on the internet to learn how to set up the complication. I have no problem getting the complication set up as expected. Until the initial timeline entries expire. After 12 hours, I do not know how to update it to keep the complication live. I'll share everything I have below and hopefully somebody can help fill me in. Here, I create the variables for my data that I want to display on the complication. struct data = { var name: String var startString:

Where and When to get data for Watch Complication

╄→尐↘猪︶ㄣ 提交于 2019-12-17 10:27:11
问题 After working with complications for a few days, I feel confident saying the following about the update process for updates that happen at a prescribed interval: The system calls requestedUpdateDidBegin() This is where you can determine if your data has changed. If it hasn't, your app doesn't have to do anything. If your data has changed, you need to call either: reloadTimelineForComplication if all your data needs to be reset. extendTimelineForComplication if you only need to add new items

watchOS - Complication shows previous entry

半腔热情 提交于 2019-12-13 02:13:12
问题 I'm creating a watchOS 3 complication that shows departure times from a public transit service. I've created a data model with an array that contains Train objects with a stationName (String) and departureTime (NSDate). I've implemented the getCurrentTimelineEntry() method and the entries are showing on the watch. The problem is that the watch shows only the previous entry. For example, I've the following departure times: Train(startStation: "Station name", endStation: "Station name",

Watchkit Complication and location updates?

徘徊边缘 提交于 2019-12-12 06:02:18
问题 I'm trying to write a complication that uses location data. I can get the location data in the complication controller but it never seems to work properly due to the results coming back asynchronously. What is the best way to update a complication with location specific data? I'm thinking that it's not a good idea to get the location in the complication (even though you can). 回答1: You should retrieve and cache the location data before the complication data source needs it. The job of your

Using three arrays to populate complication timeline

梦想与她 提交于 2019-12-12 02:59:55
问题 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

ClockKit CLKComplicationDataSource missing backward events

爷,独闯天下 提交于 2019-12-11 06:42:27
问题 I write a test app with complications support 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. Here is my function func getTimelineEntriesForComplication(complication: CLKComplication, beforeDate date: NSDate, limit: Int, withHandler handler: (([CLKComplicationTimelineEntry]?) -> Void)) { var entries:

Complication won't update

左心房为你撑大大i 提交于 2019-12-10 18:50:28
问题 I have a very simple complication with a random number. But my number won't update. Everytime I look on my watch it's the same. Only if I reinstall the complication (reinstalling apple watch app) I'm getting a new number. I have set update to 1 second. Anyone an idea what could be wrong? func getCurrentTimelineEntryForComplication(complication: CLKComplication, withHandler handler: ((CLKComplicationTimelineEntry?) -> Void)) { handler(CLKComplicationTimelineEntry(date: NSDate(),

Updating complication with Swift 3 and background task

泪湿孤枕 提交于 2019-12-09 16:39:04
问题 For watchOS 3, Apple suggests updating the complication with WKRefreshBackgroundTask instead of using getNextRequestedUpdateDate . How can I determine the time between two updates using the new approach? I would only hack my data requesting (from an url) into getCurrentTimelineEntry and would update the complication, but I think that's not really what Apple would recommend. A short code example would be a big help. 回答1: I generally covered this in a different answer, but I'll address your

Combining WatchConnectivity and Complications

戏子无情 提交于 2019-12-08 04:57:46
问题 I want my complication to get data from the iPhone via Watch Connectivity. I am using sendMessage Instant Messaging technology. I don't want my iPhone app to be open when I try to get data, so this needs to work in the background. In my ViewController on my iPhone: import UIKit import WatchConnectivity class ViewController: UIViewController, WCSessionDelegate { var session: WCSession! override func viewDidLoad() { super.viewDidLoad() if WCSession.isSupported() { self.session = WCSession