zoukankan      html  css  js  c++  java
  • iOS9新特性之关键字

    //
    //  ViewController.m
    //  01-iOS9新特性之常见关键字
    //
    //  Created by kun on 16/8/16.
    //  Copyright © 2016年 kun. All rights reserved.
    //
    
    /*
     nullable:1,怎么使用(语法)2,什么时候使用(作用)
     nullable作用:可能为空
     关键字目的:迎合swift,swift是个强语言,swift必须指定一个对象是否为空
     关键字好处:提高代码规范,减少沟通成本
    
     nullable 语法1
     @property (nonatomic, strong, nullable) NSString *name;
     nullable 语法2
     @property (nonatomic, strong) NSString *_Nullable name;
     nullable 语法3
     @property (nonatomic, strong) NSString *__nullable name;
     */
    
    /*
     nonnull:1,怎么使用(语法)2,什么时候使用(作用)
     nonnull作用:不能为空
     
     nonnull 语法1
     @property (nonatomic, strong, nonnull) NSString *name;
     nonnull 语法2
     @property (nonatomic, strong) NSString *_Nonnull name;
     nonnull 语法3
     @property (nonatomic, strong) NSString *__nonnull name;
     
     null_resettable
     nonnull
     */
    
    /*
     null_resettable:1,怎么使用(语法)2,什么时候使用(作用)
     null_resettable:必须处理为空的情况,重写get方法
     null_resettable作用:get方法不能为空, set可以传入为空
     关键字目的:迎合swift,swift是个强语言,swift必须指定一个对象是否为空
     关键字好处:提高代码规范,减少沟通成本
     
       语法1
     @property (nonatomic, strong, null_resettable) NSString *name;
     
     */
    
    /*
        _Null_unspecified:不确定是否为空
     */
    
    /*
     在下面两个宏之间的属性默认为nonnull
     NS_ASSUME_NONNULL_BEGIN
     NS_ASSUME_NONNULL_END
     */
    
    #import "ViewController.h"
    
    @interface ViewController ()
    // nullable
    // nonnull
    // null_resettable 处理为空的情况
    @property (nonatomic, strong, null_resettable) NSString *name;
    //@property (nonatomic, strong) NSString *_Nullable name;
    //@property (nonatomic, strong) NSString *__nullable name;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
    }
    - (NSString *)name
    {
        if ( _name == nil )
        {
            _name = @"";
        }
        return _name;
    }
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
  • 相关阅读:
    AppiumForWin安装
    AppiumForMac安装2
    AppiumForMac安装1
    在MacOS安装puppeteer
    puppeteerExamples
    为什么总有target=_blank?
    Canvas 与 SVG
    HTML5+CSS3兼容收藏夹
    html 5 读取本地文件API
    【Web Audio API】 — 那些年的 web audio
  • 原文地址:https://www.cnblogs.com/fkunlam/p/5775058.html
Copyright © 2011-2022 走看看