zoukankan      html  css  js  c++  java
  • 【原】Automatic Reference Counting(ARC) properties learning

    1、With ARC, you should use strong instead of retain and weak instead of assign  when defining the properties.

    @interface Person : NSObject
    @property (nonatomic, strong) NSString *firstName;
    @property (nonatomic, strong) NSString *lastName;
    @property (nonatomic, strong) NSNumber *yearOfBirth;
    @property (nonatomic, strong) Person *spouse;
    @end
    

    2、ARC forbids 'dealloc','release','autorelease' key words, these words shouldn`t be explicitly invoked!

    For instance,[super dealloc] [str release] are not permitted.

    3、When you use [[AClass alloc] init], you don`t need to release it.

    - (void)takeLastNameFrom:(Person *)person {
    
        NSString *oldLastname = [self lastName];
    
        [self setLastName:[person lastName]];
    
        NSLog(@"Lastname changed from %@ to %@", oldLastname, [self lastName]);
    //oldLastname will stay alive until NSLog is runned
    }

    4、

  • 相关阅读:
    Oracle分析函数
    oracle row_number的使用
    lru缓存测试类
    注解测试类
    lucene测试类
    SVN中检出(check out) 跟导出(export) 的区别
    Lucene原理与代码分析
    Lucene入门基础教程
    linux的less命令
    day4 大纲笔记
  • 原文地址:https://www.cnblogs.com/wengzilin/p/2482648.html
Copyright © 2011-2022 走看看