first, the support of nullability detection
1. IntroductionIn the previous OC, the development often encountered because a method should return an instance object and actually returned empty caused the application to crash, and Nullability's usefulness is here, it can prompt the developer to make a decision whether empty. In IOS 9, new keywords are presented: nullable, Nonnull, null_resettable, _null_unspecified; Note: The above keywords can only be used to modify OC objects and cannot be decorated with basic data types
2. NullableFunction: Can be empty notation:
Notation 1
@property (Nonatomic, Strong, Nullable) NSString * name_1;
Notation 2
@property (nonatomic, Strong) NSString * __nullable name_2;
Notation 3
@property (nonatomic, Strong) NSString * _nullable name_3;
3. nonnull function: Can not be empty notation:
Notation 1
@property (Nonatomic, Strong, nonnull) NSString * name_1;
Notation 2
@property (nonatomic, Strong) NSString * __nonnull name_2;
Notation 3
@property (nonatomic, Strong) NSString * _nonnull name_3;
Note: Between Ns_assume_nonnull_begin and Ns_assume_nonnull_end, all defined objects and methods default to Nonnull
4. null_resettable Function: Getter method cannot return null; Setter method can be written as follows:
@property (Nonatomic, Strong, null_resettable) NSString * name_1; Note: If you use Null_resettable, you must override the getter or setter method
5. Null_unspecified Effect: Unsure whether an empty notation:
Notation 1
@property (nonatomic, Strong) NSString * __null_unspecified name_1;
Notation 2
@property (nonatomic, Strong) NSString * _null_unspecified name_2;
two, type wildcard characters 1. In the program often meets with ObjectType, it is neither a type nor a keyword, just a type wildcard
third, __kindof function: Indicates the current class or its subclasses write:
__kindof classname *