问题描述
Xcode iOS 5.1 SDK中的 strong
和弱
IBOutlets有什么区别?
What is the difference between strong
and weak
IBOutlets in the Xcode iOS 5.1 SDK?
我之前使用的是4.3 SDK,其中没有强大的IBOutlets。此外,iOS 5.1 SDK中不提供(自动)版本。
I was previously using the 4.3 SDK, where strong IBOutlets did not exist. In addition, (auto)release is not available in the iOS 5.1 SDK.
推荐答案
强大
表示只要此属性指向一个对象,该对象就不会自动释放。在非ARC中,它是 retain的同义词
Strong
means that as long as this property points to an object, that object will not be automatically released. In non-ARC it's a synonym for retain
弱
相反,意味着属性指向的对象可以自由释放,但前提是它将属性设置为NULL。在ARC中你使用weak来确保你不拥有它指向的对象
Weak
instead, means that the object the property points to, is free to release but only if it sets the property to NULL. In ARC you use weak to ensure you do not own the object it points to
Nonatomic
表示如果多个线程尝试一次读取或更改属性,则可能发生错误。后果是会有部分写入的值或过度释放的对象= CRASH。
Nonatomic
means that if multiple threads try to read or to change the property at once, badness can happen. Consequences are that there will be partially-written values or over-released objects = CRASH.
看看了解更多关于 strong
和弱的信息
。
Check also this to know more about strong
and weak
.
这篇关于强弱IBOutlets之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!