iOS9 的新特性(部分)

non null \  _nonnull

setter 和 getter 都不能为nil

//@property (nonatomic, strong, nonnull) NSArray *names;

//@property (nonatomic, strong) NSArray * __nonnull names;

nullable \ _nullable:

setter 和 getter 都可以为nil

默认情况下,不加nullable,setter 和 getter 都可以为nil

nullable更多的作用是在于程序员之间的沟通交流

//@property (nonatomic, strong, nullable) NSArray *names;

//@property (nonatomic, strong) NSArray * __nullable names;

null_resettable :setter 可以为nil ,getter 不可以为nil

//@property (null_resettable, nonatomic, strong) NSArray *names;

//错误写法

//@property (nonatomic, assign, nullable) int age;

写在NS_ASSUME_NONNULL_BEGIN与NS_ASSUME_NONNULL_END的属性不能为空

泛型

原本id类型的点语法是没有提示的 ,但是用上泛型就可以

self.names.lastObject.length;

//泛型

/**名字*/

@property(nonatomic,strong)NSMutableArray  names;

//    self.books[@"312323"] = @100;

//    self.books[@"jack"].stringValue;

协变性(不常用)

__covariant :

小类型(泛型类的子类类型) ->大类型(泛型类的父类类型) 

__contravariant :

大类型(泛型类的父类类型) ->小类型(泛型类的子类类型)

_kindof解决如果是子类类型接收需要进行强制转换的问题

// __kindof :告诉编译器返回值可能是NSString,也可能是NSMutableString

UIWindow

状态栏是由顶层窗口控制器决定

强制要加根控制器

在didFinishLaunchingWithOptions结束后还没有设置window的rootViewController会导致崩溃

//更新状态栏

//    [self setNeedsStatusBarAppearanceUpdate];

你可能感兴趣的:(iOS9 的新特性(部分))