+ (UIColor*) getColorWithHexa(NSString*)hexString;
这是我班上的方法定义.这引起了警告.什么是类似警告的原因以及如何解决这些问题?
我正在返回一个UIColor对象,而这个问题与块有关,在注释中给出.
所以,这很有帮助.
解决方法
NS_ASSUME_NONNULL_BEGIN/END:
Annotating any pointer in an Objective-C header file causes the
compiler to expect annotations for the entire file,bringing on a
cascade of warnings. Given that most annotations will be nonnull,a
new macro can help streamline the process of annotating existing
classes. Simply mark the beginning and end of a section of your header
with NS_ASSUME_NONNULL_BEGIN and …_END,then mark the exceptions.
所以,你只是这样做.
NS_ASSUME_NONNULL_BEGIN + (UIColor*) getColorWithHexaCode:(NSString*)hexString; NS_ASSUME_NONNULL_END
这在中定义
“NSObjCRuntime.h”
#define NS_ASSUME_NONNULL_BEGIN _Pragma(“clang assume_nonnull begin”) #define NS_ASSUME_NONNULL_END _Pragma(“clang assume_nonnull end”)