Reputation: 387
Any strategies I can use to reduce the latency when sending data between iPhone and Apple Watch?
On the simulator sometimes the lag is often >0.1s meaning the counter (see code below) will often skip some numbers. After running the counter for a few seconds the lag increases to >1s and the counter skips 10+ numbers very frequently.
I'm trying to build a spritz-like app for Apple Watch which would require words to flash on screen at speeds of ~500 words per minute or 1 word every 0.12 seconds.
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
self.number = 0;
NSTimer *t = [NSTimer timerWithTimeInterval:0.1 target:self selector:@selector(updateLabelText) userInfo:nil repeats:YES];
NSRunLoop *runner = [NSRunLoop currentRunLoop];
[runner addTimer:t forMode: NSDefaultRunLoopMode];
}
- (void)updateLabelText {
NSString *str = [NSString stringWithFormat:@"number %ld", self.number];
[self.testLabel setText:str];
self.number += 1;
}
Upvotes: 1
Views: 258
Reputation: 369
Alternatively, you can display your words as an image loop. The code allows you to specify how fast the set of images updates. So rather than using text objects, build a set of images, install it on the watch, and then display them in a loop.
Upvotes: 1
Reputation: 5536
You cannot guarantee update speeds on the Apple watch simply because of how the application communicates with the watch. UI updates are delivered usually after .1 seconds, making your sprintz like app impossible due to the current conditions.
Maybe in a future framework will apple allow native watch apps, but right now, UI is sent to the phone which severely limits the dynamism of WatchKit apps.
Upvotes: 0