nonnull、nullable、null_resettable、_Null_unspecified关键字

  • iOS 9新增关键字: 用于修饰属性或者方法的参数、方法的返回值
    • nonnull不可为空,等同于_Nonnull__nonnull
      • e.g.
@property (nonatomic,strong,nonnull) UIView *view;
@property (nonatomic,strong) UIView *_Nonnull view;
@property (nonatomic,strong) UIView *__nonnull view;
  • nullable可为空,等同于_Nullable__nullable
    • e.g.
@property (nonatomic,strong, nullable) UIView *view;
@property (nonatomic,strong) UIView *_Nullable view;
@property (nonatomic,strong) UIView *__nullable view;
  • null_resettable setter方法可传空,getter方法不为空
  • _Null_unspecified 不确认是否为空

你可能感兴趣的:(nonnull、nullable、null_resettable、_Null_unspecified关键字)