I’ve encountered this issue before with other protocols, eg NSApplicationDelegate
. This SO question discusses why this happens.
You can simply ignore the protocol conformance declaration when you define your CBCentralManager
delegate. The protocol conformance is only checked by the Objective-C compiler, not in the runtime. Here’s an example where I’ve not declared the protocol conformance for UIApplicationDelegate
and the code just works.
I used to link a stub like this, which will cause the protocol to be loaded in the runtime:
#import <UIKit/UIKit.h>
// UIApplicationDelegate protocol must be referenced in ObjC code
// in order to be loaded in the Objective-C runtime.
@interface _Dummy : NSObject <UIApplicationDelegate>
@end
@implementation _Dummy
@end
You can do something similar for CBCentralManagerDelegate
, but it’s not really necessary.
You can open a new topic here for your project related questions, or continue asking in this topic. I don’t mind it either way.