您的位置:首页 > 移动开发 > IOS开发

ios9 新特性

2016-05-04 16:23 465 查看
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]];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: