The "nullability-completeness" warning对我而言不适用于Xcode 9.3(和9.4.1)。 虽然可以在Xcode 9.1和9.2中使用。
我使用“ Single View App”模板在Xcode 9.2(或9.1)中创建了一个新的iOS项目,然后将此方法添加到ViewController.h:
- (nonnull UIView *)f:(UIView *)f g:(UIView *)g;
我在每个参数上收到2条警告,如下所示:
In file included from /Users/daniel/Projects/tests/TestNullability92/TestNullability92/ViewController.m:9:
/Users/daniel/Projects/tests/TestNullability92/TestNullability92/ViewController.h:13:31: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
- (nonnull UIView *)f:(UIView *)f g:(UIView *)g;
^
/Users/daniel/Projects/tests/TestNullability92/TestNullability92/ViewController.h:13:31: note: insert '_Nullable' if the pointer may be null
- (nonnull UIView *)f:(UIView *)f g:(UIView *)g;
^
_Nullable
/Users/daniel/Projects/tests/TestNullability92/TestNullability92/ViewController.h:13:31: note: insert '_Nonnull' if the pointer should never be null
- (nonnull UIView *)f:(UIView *)f g:(UIView *)g;
但是,如果我在Xcode 9.3(或9.4.1)中打开并重建该项目,则不会收到这些警告。
我尝试进入构建设置并显式启用此标志(尽管默认情况下应启用该标志),但仍然无济于事: