Pointer is missing a nullability type specifier

后端 未结 6 1799
情书的邮戳
情书的邮戳 2021-01-31 01:17

In Xcode 7 GM I started to get this warning:

Pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)

6条回答
  •  后悔当初
    2021-01-31 01:51

    I post this answer to tell why should add _Nonnull or nullable.

    According to this blog: https://developer.apple.com/swift/blog/?id=25

    One of the great things about Swift is that it transparently interoperates with Objective-C code, both existing frameworks written in Objective-C and code in your app. However, in Swift there’s a strong distinction between optional and non-optional references, e.g. NSView vs. NSView?, while Objective-C represents boths of these two types as NSView *. Because the Swift compiler can’t be sure whether a particular NSView * is optional or not, the type is brought into Swift as an implicitly unwrapped optional, NSView!.

    it's all for Swift.

提交回复
热议问题