简体   繁体   English

IOS:多对等连接框架

[英]IOS: Multipeer Connectivity Framework

I created an app with this code multipeer connectivity master / slave https://stackoverflow.com/a/20703659/2787079 我使用此代码多对等连接主/从https://stackoverflow.com/a/20703659/2787079创建了一个应用

So when I switch the ViewController I cant " SendDataToPeers ". 所以当我切换ViewController时,我无法“ SendDataToPeers ”。 The error says "no peers connected." 该错误显示“未连接任何对等设备”。

Any hint or tips how i can call the gunction " SendDataToPeers " in a another ViewController with the same instance / session from the first one in Objective CI don't want to connect again the slaves, they must stay connected. 任何提示或技巧,我如何能从Objective CI中的第一个实例在另一个ViewController中使用相同的实例/会话在另一个ViewController中调用“ SendDataToPeers ”功能,都不​​希望再次连接从机,它们必须保持连接状态。

创建一个单一的类来管理所有Multipeer连接(例如MCController.swift),并在您的应用程序委托中将其实例化为一个单例。这样,所有视图控制器都可以访问该单个对象(以及当前连接状态),很多情况下,与UserDefauts相同。

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

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