【原】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
}
复制代码

本文转自编程小翁博客园博客,原文链接:http://www.cnblogs.com/wengzilin/archive/2012/05/04/2482648.html,如需转载请自行联系原作者

相关文章
|
3月前
|
算法 数据挖掘 数据处理
文献解读-Sentieon DNAscope LongRead – A highly Accurate, Fast, and Efficient Pipeline for Germline Variant Calling from PacBio HiFi reads
PacBio® HiFi 测序是第一种提供经济、高精度长读数测序的技术,其平均读数长度超过 10kb,平均碱基准确率达到 99.8% 。在该研究中,研究者介绍了一种准确、高效的 DNAscope LongRead 管道,用于从 PacBio® HiFi 读数中调用胚系变异。DNAscope LongRead 是对 Sentieon 的 DNAscope 工具的修改和扩展,该工具曾获美国食品药品管理局(FDA)精密变异调用奖。
32 2
文献解读-Sentieon DNAscope LongRead – A highly Accurate, Fast, and Efficient Pipeline for Germline Variant Calling from PacBio HiFi reads
|
人工智能 编解码 自动驾驶
YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
YOLOv7在5 FPS到160 FPS的范围内,在速度和精度方面都超过了所有已知的物体检测器,在GPU V100上以30 FPS或更高的速度在所有已知的实时物体检测器中具有最高的精度56.8% AP。
473 0
|
机器学习/深度学习 算法
Re9:读论文 DEAL Inductive Link Prediction for Nodes Having Only Attribute Information
Re9:读论文 DEAL Inductive Link Prediction for Nodes Having Only Attribute Information
Re9:读论文 DEAL Inductive Link Prediction for Nodes Having Only Attribute Information
|
存储 容器
Data Structures and Algorithms (English) - 7-18 Hashing - Hard Version(30 分)
Data Structures and Algorithms (English) - 7-18 Hashing - Hard Version(30 分)
223 0
Data Structures and Algorithms (English) - 7-18 Hashing - Hard Version(30 分)
MGA (Managed Global Area) Reference Note (Doc ID 2638904.1)
MGA (Managed Global Area) Reference Note (Doc ID 2638904.1)
340 0
|
机器学习/深度学习 算法 数据挖掘
Paper:He参数初始化之《Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet C》的翻译与解读
Paper:He参数初始化之《Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification》的翻译与解读
PAT (Advanced Level) Practice - 1049 Counting Ones(30 分)
PAT (Advanced Level) Practice - 1049 Counting Ones(30 分)
122 0
Data Structures and Algorithms (English) - 6-2 Two Stacks In One Array(20 分)
Data Structures and Algorithms (English) - 6-2 Two Stacks In One Array(20 分)
148 0
PAT (Advanced Level) Practice - 1004 Counting Leaves(30 分)
PAT (Advanced Level) Practice - 1004 Counting Leaves(30 分)
114 0
|
C++
PAT (Advanced Level) Practice - 1038 Recover the Smallest Number(30 分)
PAT (Advanced Level) Practice - 1038 Recover the Smallest Number(30 分)
129 0