我读这个官方指导价:https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html#//apple_ref/doc/uid/TP40004447-SW13和我不知道它是指处理引用计数的旧方法还是只是为了演示它是如何工作的-但是否应该像使用访问器的示例那样手动使用保留/释放?
不允许retain
与ARC一起使用。但是,它在后台的工作原理与没有ARC时(和链接的文档中所述)相同,但编译器会根据需要添加retain
和release
调用。您不必处理。
这个二传手:
- (void)setCount:(NSNumber *)newCount {
[newCount retain];
[_count release];
// Make the new assignment.
_count = newCount;
}
使用ARC时应如下所示:
- (void)setCount:(NSNumber *)newCount {
// Make the new assignment.
_count = newCount;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句