標籤:
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 新特性