mapanguan

导航

iOS9 新加关键字 nullable、nonnull、null_unspecified、null_resettable

#import "ViewController.h"

@interface ViewController ()

@property(nonatomic,nullable)NSString*name;//可以为空
@property(nonatomic,nonnull)NSString*password;//不可为空
@property(nonatomic,null_unspecified)NSString*unkonw;//未知类型

@property(nonatomic)NSString* _Nullable name1;//可以为空
@property(nonatomic)NSString* _Nonnull password1;//不可为空
@property(nonatomic)NSString* _Null_unspecified unkonw1;//未知类型

@property(nonatomic)NSString* __nullable name2;//可以为空
@property(nonatomic)NSString* __nonnull password2;//不可为空
@property(nonatomic)NSString* __null_unspecified unkonw2;//未知类型

@property(nonatomic,null_resettable)NSString*setStr;//get方法不能为空,set方法可以为空

-(void)creatDemoWithName:(nullable NSString*)name PSW:( NSString* _Nonnull )psw UnkonwStr:(null_unspecified NSString*)unkownStr;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self creatDemoWithName:nil PSW:@"heheheh" UnkonwStr:nil];
   
}

-(void)setSetStr:(NSString *)setStr{

   self.setStr = @"hehehe";
    
}


-(void)creatDemoWithName:(nullable NSString*)name PSW:( NSString* _Nonnull )psw UnkonwStr:(null_unspecified NSString*)unkownStr{

    NSLog(@"%@=%@=%@",name,psw,unkownStr);

}

posted on 2016-05-11 09:28  mapanguan  阅读(418)  评论(0编辑  收藏  举报