Does the Objective-C compiler actually warn you if it thinks that you may be passing nil to a parameter marked with _Nonnull?
Or is it merely a hint to whatever tool converts between Swift and Objective-C to better deal with Swift optionals?
Does the Objective-C compiler actually warn you if it thinks that you may be passing nil to a parameter marked with _Nonnull?
Or is it merely a hint to whatever tool converts between Swift and Objective-C to better deal with Swift optionals?
Copyright © 2021 Jogjafile Inc.
On its own, there is warning only in the extremely trivial case: when you pass
nilto a function accepting_Nonnullvalue.(There is a
-Wnullable-to-nonnull-conversionflag but it doesn't seem to have any effect to the code above.)As documented, the three attributes will not change the behavior of the code:
Beyond the compiler, it will also help the static analyzer, but again clang's static analyzer will only catch the trivial case where it knows for sure you are assigning a
nilto a_Nonnull(i.e. thetest(f)example above).Nevertheless, it is still useful to mark a pointer
_Nonnull/_Nullableas