watchkit 应用程序如何与 ios 中的 iphone 父应用程序通信

How watchkit app communicate with iphone parent application in ios

嗨,我想在手表套件应用程序上实现示例应用程序。我想显示父应用程序的一些信息,即 iphone 中的 运行,现在我想从点击手表套件按钮的预成型动作中获取手表套件应用程序中的数据。我已经使用委托方法与扩展应用程序进行后台通信,但是当我在

中打印错误时出现相同的错误
[InterfaceController openParentApplication:dict reply:^(NSDictionary *replyInfo, NSError *error) 
{ 
    NSLog(@"%@",[replyInfo objectForKey:@"Key"]); 
    NSLog(@"error:-%@",[error description]);
}

获取错误....

Error: Error Domain=com.apple.watchkit.errors Code=2 "The UIApplicationDelegate in the iPhone App never called reply() in -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:]" UserInfo=0x7f8603227730 {NSLocalizedDescription=The UIApplicationDelegate in the iPhone App never called reply() in -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:]}

请建议我如何从扩展应用程序获取手表应用程序中的数据。 提前致谢。

在我的手表应用程序中,我想设置我的地图视图,所以我向我的应用程序询问位置。

- (void)awakeWithContext:(id)context {
    [super awakeWithContext:context];

    // Configure interface objects here.
    [WKInterfaceController openParentApplication:@{} reply:^(NSDictionary *replyInfo, NSError *error) {
        if (replyInfo) {

            [self.map setRegion:MKCoordinateRegionMake(CLLocationCoordinate2DMake([replyInfo[@"lat"] doubleValue], [replyInfo[@"lon"] doubleValue]), MKCoordinateSpanMake(0.05, 0.05))];
        }
    }];
}

然后我从我的应用程序委托中放回位置:

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]];
    reply(@{@"lat": @"22.3175899",@"lon": @"114.2212058"});
}