Tag: 客观可控性

Objective-C中nullable,__nullable和_Nullable之间的区别

使用Xcode 6.3,为了更好地expressionAPI在Objective-C中的意图(并确保更好的Swift支持),引入了新的注释。 这些注释当然null_unspecified nullable , nullable , null_unspecified nullable null_unspecified 。 但是在Xcode 7中,出现了很多警告,比如: 指针缺less可为空types说明符(_Nonnull,_Nullable或_Null_unspecified)。 除此之外,苹果公司使用另一种types的可空性说明符,标记他们的C代码( 来源 ): CFArrayRef __nonnull CFArrayCreate( CFAllocatorRef __nullable allocator, const void * __nonnull * __nullable values, CFIndex numValues, const CFArrayCallBacks * __nullable callBacks); 所以,总结一下,我们现在有3个不同的可空性注释: nonnull nullable , nullable , null_unspecified _Nonnull , _Nullable , _Null_unspecified __nonnull , __nullable , __null_unspecified 尽pipe我知道为什么以及在哪里使用哪个注释,我对使用哪种types的注释,在哪里以及为什么会有些困惑。 […]