0

I've changed a label in iOS app via an api. It changed successfully. Now I want to show this label value in Apple Watch Label.
I tried doing it by InterfaceController *ic; and doing it's alloc & init and then where my api get success I'm doing ic.myLabel.text = [NSString stringWithFormat:@"%@",[tempDict objectForKey:@"summary"]];

So it is not working. Any clues?

AstroCB
  • 12,337
  • 20
  • 57
  • 73
Chaudhry Talha
  • 7,231
  • 11
  • 67
  • 116

1 Answers1

3

You can request data from iOS app. Need to implement this method in Watch App:

[WKInterfaceController openParentApplication:@{@"KEY":@"getValue"}
                                       reply:^(NSDictionary *replyInfo, NSError *error) {
                                      [self updateLabelWithString:replyInfo(@"value")];
                                       }];

And in iOS app AppDelegate:

- (void)application:(UIApplication *)applicationhandleWatchKitExtensionRequest:(NSDictionary *)userInfo
          reply:(void (^)(NSDictionary *replyInfo))reply
{
reply(@{@"value":@"your data"});
}

The app delegate performs the request using the provided dictionary and then returns a reply to the WatchKit extension.

  • 1
    You could also look into using Darwin notifications to notify the WatchKit app right away, if it's currently running. Check out MMWormhole to make this easier: https://github.com/mutualmobile/MMWormhole – bgilham Apr 16 '15 at 13:48
  • @bgilham Seems great. Let me give it a try. – Chaudhry Talha Apr 17 '15 at 05:51