0

I have a viewController that implements coreBluetooth on my objective c application. I initialize my CBCentralManager on a viewController, but I want reconnect and use didDiscoverPeripheral from another viewController and from APpDelegate.

If I use to init this code:

@property (strong,nonatomic) CBCentralManager *central;

...

self.central=[[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)];

How can I use the coreBlueooth delegates function without need reset and initialize again the CBCentralManager?

Hope be clear.

user3745888
  • 6,143
  • 15
  • 48
  • 97
  • Move the CBCentralManager out into some other class and pass a reference to an instance of that class around. You can use NSNotification to notify your view controllers of blue tooth events – Paulw11 Apr 14 '17 at 00:02
  • 1
    See https://github.com/paulw11/BTMonitor for an example – Paulw11 Apr 14 '17 at 00:24
  • Singleton Pattern, often with method `sharedInstance` to get it is a way to do that. – Larme Apr 14 '17 at 08:18

0 Answers0