简体   繁体   English

iOS GKSession一段时间后停止搜索设备

[英]iOS GKSession Stop Searching Devices after a while of time

I want to develop an app that can send data between 2 or more iOS devices using bluetooth or wifi. 我想开发一个可以使用蓝牙或wifi在2个或更多iOS设备之间发送数据的应用程序。 I find GameKit framework can help me do that. 我发现GameKit框架可以帮助我做到这一点。 My problems are: 我的问题是:

  1. How can I stop searching devices process after a while of time without any devices found? 一段时间后如何停止搜索设备进程而没有找到任何设备? I've implemented GKPeerPickerController and when I press my button it will start searching devices process. 我已经实现了GKPeerPickerController,当我按下按钮时,它将开始搜索设备进程。 I want after 10 seconds if there is no devices found, I will stop searching and notify user that there's no devices near here. 我想要10秒后,如果找不到任何设备,我将停止搜索并通知用户附近没有设备。

  2. How can I specified that time for myself? 我如何为自己指定时间? Is there any property for me to set for the time like 10 seconds I indicated above. 我是否可以为上述10秒钟的时间设置任何属性。

Thanks 谢谢

I've found that I can manage connection with GKSession, it doesn't need to use GKPeerPickerController. 我发现我可以管理与GKSession的连接,不需要使用GKPeerPickerController。 Just set property "available" of GKSession to YES or NO to start or stop searching devices to connect. 只需将GKSession的属性“ available”设置为YES或NO,即可启动或停止搜索要连接的设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM