Common keywords, generics for new features of IOS9

Source: Internet
Author: User

#pragma mark--nullable


Nullable: Can be empty, only adornment object, cannot decorate basic data type
Way One:
@property (nonatomic, copy, nullable) NSString *name;
Way two:
@property (nonatomic, copy) nsstring *_nullable name;
Way three:
@property (nonatomic, copy) nsstring *__nullable name;

Method in
-(Nullable NSString *) Test: (Nullable NSString *) str;
-(NSString * _nullable) Test1: (NSString * _nullable) str;

#pragma mark--nonnull

Nonnull: cannot be empty, can only decorate object, cannot decorate base data type

Way One:
@property (nonatomic, copy, nonnull) NSString *name;
Way two:
@property (nonatomic, copy) NSString * _nonnull name;
Way three:
@property (nonatomic, copy) NSString * __nonnull name;

Method in
-(nonnull NSString *) Test: (nonnull nsstring *) str;
-(NSString * _nonnull) Test1: (NSString * _nonnull) str;

#pragma mark--null_resettable

Null_resettable:get: Cannot return null, set can be empty

@property (nonatomic, copy, null_resettable) NSString *name;


Note: If you use Null_resettable, you must override the Get method or set method to handle the case where the passed value is empty


#pragma mark--_null_unspecified

_null_unspecified: Not sure whether it is empty

Way One
@property (nonatomic, copy) nsstring *_null_unspecified name;
Way Two
@property (nonatomic, copy) nsstring *__null_unspecified name;

#pragma mark-Generics

@property (nonatomic, strong) nsmutablearray<nsstring *> *arraym;

Indicates that the object stored in the Arraym array can only be an object of type NSString

Develop specifications, remove objects from arrays, use directly as generic objects, and use point syntax directly to improve development efficiency

#pragma mark--__kindof

__kindof Person *: Indicates that the return value can be the person class or its subclass, and it is clear that the type of the return value is available when used outside

+ (__kindof person *) person;

Have any questions about iOS development! Welcome to the message below!!! or email [email protected] Although I'm not sure I can answer it, I'll ask iOS developers!!! Answers to your questions!!!

Common keywords, generics for new features of IOS9

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.