WatchKit:handleWatchKitExtensionRequest多个实例 [英] WatchKit : handleWatchKitExtensionRequest multiple instances

查看:147
本文介绍了WatchKit:handleWatchKitExtensionRequest多个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个父应用程序登录到服务器,创建用户等。然后我使用WatchApp中的handleWatchKitExtensionRequest访问父应用程序,但一切都为空。

So I have a parent app that logs in to a server, creates a user etc. I then use handleWatchKitExtensionRequest from the WatchApp to access the parent app but everything is null.

我的问题是,handleWatchKitExtensionRequest是否在不同的实例中运行到父应用程序?我在某个地方读到了它,但我只需要确认。

My question is, does handleWatchKitExtensionRequest get run in a different instance to the parent app? I read somewhere it does but I just need this confirmed.

谢谢

推荐答案

如果 handleWatchKitExtensionRequest 返回任何内容,则表示永远不会调用传递的回复。这很可能是由于 application.didFinishLaunchingWithOptions 在后台模式下启动应用程序时遇到错误。

If handleWatchKitExtensionRequest returns nothing it means that the passed reply is never called. This is most probably due to application.didFinishLaunchingWithOptions runs into an error when the app is launched in background mode.

我的应用程序遇到了类似的问题,我在应用程序的navigationController上做了一些初始化。事实证明,当应用程序以后台模式启动时,无法访问navigationController。

I had a similar issue with my app where I did some initializations on the app's navigationController. It turned out that the navigationController is not accessible when the app is launched in background mode.

我建议完全注释掉中的代码didFinishLaunchingWithOptions 并查看 handleWatchKitExtensionRequest 是否调用回复。如果是这样,请逐步取消注释 didFinishWithLaunchingWithOptions 中的代码以检测错误代码。

I would suggest to completely comment out the code in didFinishLaunchingWithOptions and see if handleWatchKitExtensionRequest calls its reply. If so, uncomment the code in didFinishWithLaunchingWithOptions step by step to detect the faulty code.

这可能真的很难跟踪,因为在启动时无法将调试器附加到iPhone应用程序。

This may be really hard to track down because one cannot attach the debugger to the iPhone app at this time of launching.

另一个陷阱:
handleWatchKitExtensionRequest 在Swift 1.2中已更改,但没有给出任何编译器错误。花了我几个小时来弄明白。

Another pitfall: The function signature of handleWatchKitExtensionRequest has changed in Swift 1.2 without giving any compiler errors. It took me hours to figure that out.

这篇关于WatchKit:handleWatchKitExtensionRequest多个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆