标签:
1,ARC 是编译器做的事情(在编译期间插入内存管理相关代码)
ARC evaluates the lifetime requirements of your objects and automatically inserts appropriate memory management calls for you at compile time
2,即使是局部指针变量(属性变量、局部变量 are strong
by default),所指对象引用计数也将+1
ARC ensures that oldLastName
is not deallocated before the NSLog
statement.
- (void)takeLastNameFrom:(Person *)person { |
NSString *oldLastname = [self lastName]; |
[self setLastName:[person lastName]]; |
NSLog(@"Lastname changed from %@ to %@", oldLastname, [self lastName]); |
} |
3,ARC仅仅维护了内存管理,其它的资源还是要手动置空或释放
(记得scrollview滑动时候退出页面 某些系统(因老的sdk中delegate为assign?)会crash)
You do not have to (indeed you cannot) release instance variables, but you may need to invoke [systemClassInstance setDelegate:nil]
on system classes and other code that isn’t compiled using ARC.
4,new是可以作为属性字段名的,需要重写get方法
// Won‘t work: |
@property NSString *newTitle; |
// Works: |
@property (getter=theNewTitle) NSString *newTitle; |
标签:
原文地址:http://www.cnblogs.com/xzoscar/p/5502306.html