【原】Automatic Reference Counting(ARC) properties learning
2012-05-04 14:17
543 查看
1、With ARC, you should use strong instead of retain and weak instead of assign when defining the properties.
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.
4、
@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、
相关文章推荐
- Xcode 4.2 中的Automatic Reference Counting (ARC)
- 了解Xcode 4.2中Automatic Reference Counting(ARC)
- Automatic Reference Counting(ARC)特性学习(iOS5新特性学习之五)
- 如何在项目中开始使用ARC(Automatic Reference Counting)
- ARC(Automatic Reference Counting )技术概述
- 再续 Xcode 4.2 中的Automatic Reference Counting (ARC)
- Xcode 4.2 中的Automatic Reference Counting (ARC)
- Xcode 4.2 中的Automatic Reference Counting (ARC)
- Xcode 4.2 中的Automatic Reference Counting (ARC) (转)
- Xcode 4.2 中的Automatic Reference Counting (ARC)
- ARC(Automatic Reference Counting )技术概述
- does not support Objective-C Automatic Reference Counting (ARC)
- ARC专题:Xcode 4.2 中的Automatic Reference Counting (ARC)转
- ARC(Automatic Reference Counting )技术概述
- ARC(Automatic Reference Counting )技术概述(转)
- ARC专题:再续 Xcode 4.2 中的Automatic Reference Counting (ARC)
- Automatic Reference Counting (ARC)
- 自动引用计数(ARC Automatic Reference Counting)
- IOS开发之---ARC(Automatic Reference Counting)