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?
Asked
Active
Viewed 333 times
0

AstroCB
- 12,337
- 20
- 57
- 73

Chaudhry Talha
- 7,231
- 11
- 67
- 116
-
1Where are you attempting to change the label? In your WatchKit extension? You can't do it directly from the iOS app. – bgilham Apr 16 '15 at 12:41
-
yes exactly. Then how can I do that? – Chaudhry Talha Apr 16 '15 at 13:05
1 Answers
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.

Vladyslav Zubkov
- 375
- 1
- 8
-
1You 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
-