IOS9 New Keywords: used to modify attributes, or method parameters, the return value of the method
IOS9 New Keyword Nonnull,nullable,null_resettable,_null_unspecified
One thing to be aware of is that you can only decorate objects and not modify basic data types.
Although it is not often used in code writing for a project, it is often encountered when invoking the Apple system method, which requires a summary
Nullable function: The expression can be empty
Nullable writing Specification:
//Mode one:
@property (Nonatomic, Strong, nullable) NSString *name;
Mode two:
@property (nonatomic, strong) NSString *_nullable name;
Mode III:
@property (nonatomic, strong) NSString *__nullable name;
nonnull function: cannot be empty
Nonnull:non: non-null: null
writing format:
@property (nonatomic, Strong, nonnull) NSString *icon;
@property (nonatomic, Strong) NSString * _nonnull icon;
@property (nonatomic, Strong) NSString * __nonnull icon;
Between Ns_assume_nonnull_begin and Ns_assume_nonnull_end, all object properties and methods that are defined by default are nonnull
null_resettable function: Get: Cannot return to NULL, set can be empty
Writing methods:
@property (nonatomic, Strong, null_resettable) NSString *name;
Note that if you use null_resettable, you must override the Get method or the set method to handle the case where the passed value is null
_null_unspecified: not sure if null
This is the only
way to write a
@property (nonatomic, strong) NSString *_null_unspecified name;
Mode two
@property (nonatomic, strong) NSString *__null_unspecified name;
__kindof: Represents the current class or its subclasses
__KINDOF Writing format:
Put in front of the type, indicating that the type is decorated (__kindof MyCustomClass *)
__kindof: When called, it is clear that the return type uses the __kindof-decorated class name to either represent the current class or to represent the subclass of the current class
The above is a small set to introduce the iOS generics nullable, null resettable, NULL KINDOF usage details, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!