中观看
我能够使用
将数据发送到父级应用[WKInterfaceController openParentApplication:applicationData reply:^(NSDictionary *replyInfo, NSError *error) {}]
API,但是如何从iPhone发送数据以在目标c。
您有一些方法可以实现这一目标。最简单的是使用mm虫。
您使用:
发送数据[self.wormhole passMessageObject:@{@"titleString" : title}
identifier:@"messageIdentifier"];
您使用:
收到它[self.wormhole listenForMessageWithIdentifier:@"messageIdentifier"
listener:^(id messageObject) {
// Do Something
}];
请注意,虫洞使用应用程序组进行交流,因此您需要启用它。
MM虫孔在引擎盖下使用的是CFNotificationCenterGetDarwinNotifyCenter
。实现很简单,如果您想执行自己的实现,则在此中型帖子中拥有有关CFNotificationCenterGetDarwinNotifyCenter
的更多信息。
在您的手机上执行的任何代码都在手机上完成,手表基本上充当外部屏幕