I'm using a common pattern to lazily create a var:
private lazy var peripheralManager: CBPeripheralManager = { CBPeripheralManager(delegate: self, queue: self.queue, options: nil) }()
init?(uuid: NSUUID, major: Int, minor: Int) {
...
super.init()
peripheralManager.isAdvertising // has no affect, but will insure we instantiate peripheralManagerI haven't actually tested the above - I was doing peripheralManager.startAdvertising() but that's the wrong thing to do at this point for this class.
What I have there - retrieving the value of a class var - seems fragile. The optimizer could (in the future if it doesn't now) determine that calling this var has no side effects, and since its not use just remove the statement.
So I'm sort of stuck - I can make the var la forced unwrapped optional, or I can call some method that I know will fail hoping it doesn't introduce side effects to that object.
Suggestions?