2
votes

Are multiple CBCentralManager instances supported? If so, in which version of iOS did they begin to be supported?

I've found multiple emails on the Apple mailing lists stating that they are not. However, this is not enforced with exceptions or by having a theoretical +sharedCentralManager. One states that the documentation says that they are not supported. However, that is no longer mentioned in the documentation, and the current header file comment (iOS 8.3 SDK) is:

/*!
 *  @class CBCentralManager
 *
 *  @discussion Entry point to the central role. Commands should only be issued when its state is <code>CBCentralManagerStatePoweredOn</code>.
 *
 */

I don't expect CBPeripheral instances to be portable between CBCentralManager instances (that's not what this question is about), I'd just expect to have multiple "windows" into the Bluetooth stack (without any irregular behavior).

1
It would be better to have a single CBCentralManager instance and design your app around that. Why do you need multiple? - Paulw11
I don't see how that's "better" - especially since that's essentially forcing a singleton, which I generally consider poor design. Either it works or it doesn't. If it doesn't work, fair enough, but this appears to be completely undocumented (and it was previous documented, thus the question). - user4691305

1 Answers

2
votes

As of iOS 8.3, it appears that creating a second CBCentralManager instance will cause the second instance to report its state as CBCentralManagerStateUnsupported (2). Therefore, multiple instances of CBCentralManager are not supported.