How to conform to CBCentralManagerDelegate Protocol?

前端 未结 5 597
后悔当初
后悔当初 2021-01-18 13:31

I am trying to initialize a central manager instance to make an app with Bluetooth connectivity.

This is part of my code:

class ViewController: UIVie         


        
5条回答
  •  梦毁少年i
    2021-01-18 14:20

    The error message is a little deceiving and is pointing you away from the actual issue. The problem is that you are accessing self in the initializer for a stored property, which you can't do like this.

    One workaround is to simply declare the property without initializing it, and then move the assignment to the variable to somewhere like an initializer for your view controller, or one of your view controller's lifecycle methods, like viewDidLoad.

提交回复
热议问题