起因是遇到了一个页面不刷新的问题,后来经过调查是由于 lazy 变量被重入两次导致刷新的界面跟组件持有的界面不是同一个导致的。
翻阅了一下swift的文档发现有一行小字说明。。。参考地址
Note
If a property marked with the lazy modifier is accessed by multiple threads simultaneously and the property hasn’t yet been initialized, there’s no guarantee that the property will be initialized only once.
因此对于页面元素使用到lazy变量初始化的时候,对这些变量的操作尽量放在 viewdidloaded 之后来进行,以避免不必要的麻烦。