【发布时间】:2015-01-23 14:49:37
【问题描述】:
我正在尝试将信息从我的 WatchKit 应用程序发送到我的主父应用程序,据我所知,我应该能够在我的 watchkit 扩展中使用openParentApplication,这将由 AppDelegate.swift 中的handleWatchKitExtensionRequest 接收,但我似乎无法触发handleWatchKitExtensionRequest。
我遇到了一些问题,所以此时我只是尝试建立任何连接,然后再担心实际传递了哪些信息。所以目前在我的 Watchkit ViewController 我有以下内容:
let testDict = [
"value1" : "Test 1",
"value2" : "Test 2"
]
@IBAction func saveButtonFunction() {
openParentAppForBalance(testDict)
}
private func openParentAppForInfo(Dict: [String: String]) {
WKInterfaceController.openParentApplication(testDict,
reply: {(reply, error) -> Void in
println("openParentApplication called in button function")
})
}
在输出中显示该函数正在被调用,但 handleWatchKitExtensionRequest 只是不会响应。目前它在 AppDelegate.swift 中设置为以下内容,永远不会被调用:
func application(application: UIApplication!, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]!, reply: (([NSObject : AnyObject]!) -> Void)!) {
println("we made it!")
var retValues = Dictionary<String,String>()
retValues["retval1"] = "return Test 1"
retValues["retval1"] = "return Test 2"
reply(retValues)
}
我敢肯定,在我理解这一切是如何运作的方面,我可能只是遗漏了一些真正基础的东西,但是对于如何触发 handleWatchKitExtensionRequest 的任何帮助将不胜感激!
【问题讨论】:
标签: ios swift watchkit watchos