ios9 新特性

來源:互聯網
上載者:User

標籤:

NS_ASSUME_NONNULL_BEGIN

NS_ASSUME_NONNULL_END

在這兩個之間必須屬性賦值不可以為空白

null_resettable 允許set為空白 get不為空白   需要重寫set 方法

@property(null_resettable,strong,nonatomic)NSMutableArray * allDetailData;
@property(null_resettable,strong,nonatomic)NSMutableArray * allDetailData;

nonnull 屬性賦值不可以為空白 相反nullable可以
@property(nonnull,strong,nonatomic)NSMutableArray * allDetailData;

泛型
可以是設定一些集合中的資料賦值添加對象的屬性

@property(strong,nonatomic)NSArray<NSString*>*explainArray;//警告只能為字串這個的好處就是在得到資料的可以直接得到數組

@property(nonatomic,strong)NSDictionary<NSString*,NSNumber*>  *dic ;key 是字串 value 是number

自訂泛型

#import <Foundation/Foundation.h>

@interface car<ObjectType>: NSObject
-(void)add:(ObjectType)name;
@end

__covariant 小類型轉大類型

__contravariant 大變小 無警告

 

__kindof

//__kindof 告訴編譯器可以是NSString 也可能是NSString的子類
-(__kindof NSString*)text;

原生例子 (tableview 去除某個cell)

- (nullable __kindof UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;   // returns nil if cell is not visible or index path is out of range

    [tableview cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];

 

ios9 新特性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.