They are NSObjects and you can instantiate them even thought their initializers are private. In one of my apps I use the following approach to mock NSObject classes with private initializers. In case of CBPeripheral the following can be used as a start (assuming you are using Swift):
let p = CBPeripheral.perform(NSSelectorFromString("new")).takeRetainedValue() as! CBPeripheral
In my case I use the helper:
func create<O : NSObject>(_ class: O.Type = O.self) -> O {
return O.perform(NSSelectorFromString("new")).takeRetainedValue() as! O
}
let p = create(CBPeripheral.self)
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: