首页 > 移动平台 > 详细

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

时间:2016-05-11 11:09:53      阅读:236      评论:0      收藏:0      [点我收藏+]
#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);

}

技术分享技术分享

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

原文:http://www.cnblogs.com/mapanguan/p/5480745.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!