更新时间:2023-02-03 08:03:04
在初始化每个没有默认值且不是默认值的非lazy
属性之前,无法在init
方法中使用self
可选(默认值为nil
).
There is no way to use self
in an init
method prior to initializing every non-lazy
property that has no default value and is not optional (which have a default value of nil
).
如果您总是在init
中初始化centralManager
,并且没有可能使其成为nil
的代码,那么我想说CBCentralManager!
声明是一个不错的选择.这是隐式展开的可选类型的主要目的之一.
If you always initialize centralManager
in init
, and you have no code that will potentially make it nil
, I would say that the CBCentralManager!
declaration is a good choice. That is one of the main purposes of the implicitly unwrapped optional type.