How To Store a CBPeripheral For Use in Other Views

谁说我不能喝 提交于 2019-12-04 03:07:36

Create a singleton that implements all of all your CBCentralManagerDelegate methods. Then just create your own delegate methods for that singleton to message your viewControllers. That way you can easily use it in any class. As for storing the CBPeripherals, you can just place them inside of an NSMutableArray contained inside of your singleton.

Check out this link on how to Create a Singleton Instance

(Oh and for where you say "Initialize it in other view controllers"..That should not ever be the case. But maybe you just mean to store the CFUUIDRef? If you do that, you can just call retrievePeripherals:(NSArray*) and get the peripheral object back wherever you want. If thats what you mean...)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!