如何在swift中将数据从iphone发送到watchkit

我正在做一个示例项目,我喜欢将数据从iphone发送到WatchKit.我不知道该怎么做.任何帮助将不胜感激.提前致谢
在AppDelegate中添加方法
func application(application: UIApplication!,handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]!,reply: (([NSObject : AnyObject]!) -> Void)!)
{
   //define your dictionary
   reply(yourDict)
}

在Apple Watch Extension中的任何位置添加

var dict = ["test" : 4] //your dictionary/request to sent to the iPhone
if !WKInterfaceController.openParentApplication(dict,reply: { (reply,error) -> Void in
    println("\(reply)") //your reply data as Dictionary
}) {
    println("ERROR")
}

一个函数将使用WKInterfaceController.openParentApplication触发,并将在reply参数中回复字典.

开发者论坛:
https://devforums.apple.com/message/1082689#1082689

相关文章

软件简介:蓝湖辅助工具,减少移动端开发中控件属性的复制和粘...
现实生活中,我们听到的声音都是时间连续的,我们称为这种信...
前言最近在B站上看到一个漂亮的仙女姐姐跳舞视频,循环看了亿...
【Android App】实战项目之仿抖音的短视频分享App(附源码和...
前言这一篇博客应该是我花时间最多的一次了,从2022年1月底至...
因为我既对接过session、cookie,也对接过JWT,今年因为工作...