1

Swift 编译器抱怨

let insets : UIEdgeInsets? = UIApplication.shared.delegate?.window?.safeAreaInsets

带有错误消息

Value of optional type UIWindow? must be unwrapped to refer to member safeAreaInsets of wrapped base type UIWIndow. Chain the optional using '?' to access member safeAreaInsets only for non-nil base values.

编码

let insets : UIEdgeInsets? = UIApplication.shared.delegate?.window??.safeAreaInsets

工作正常。为什么必填后的第二个问号window?这里的两个问号似乎不构成 nil-coalescing 运算符。我显然错过了一些东西。

4

0 回答 0