iphone - 强IBOutlets和弱IBOutlets的区别

标签 iphone ios xcode ios5

Xcode iOS 5.1 SDK 中的 strongweak IBOutlets 有什么区别?

我之前使用的是 4.3 SDK,其中不存在强大的 IBOutlets。此外,(自动)发布在 iOS 5.1 SDK 中不可用。

最佳答案

Strong 表示只要这个属性指向一个对象,那个对象就不会自动释放。在非 ARC 中,它是 retain

的同义词

Specifies that there is a strong (owning) relationship to the destination object.

Weak 相反,意味着属性指向的对象可以自由释放,但前提是它将属性设置为 NULL。在 ARC 中,您使用 weak 来确保您不拥有它指向的对象

Specifies that there is a weak (non-owning) relationship to the destination object. If the destination object is deallocated, the property value is automatically set to nil.

Nonatomic 意味着如果多个线程同时尝试读取或更改属性,就会发生错误。结果是将有部分写入的值或过度释放的对象 = CRASH。

也看看here, at Apple's documents .

从那里开始,例子是

@property (weak) IBOutlet MyView *viewContainerSubview;
@property (strong) IBOutlet MyOtherClass *topLevelObject;

同时检查 this了解更多关于 strongweak 的信息。

关于iphone - 强IBOutlets和弱IBOutlets的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11168992/

相关文章:

css - 停用默认值 :active behaviour on ios

ios - 如何使用搜索栏搜索多个 View ? (iOS swift )

iphone - 从应用程序下载 "mobileconfig"文件

iphone - 从 NSURLResponse 检测 NSStringEncoding 的函数?

javascript - 使用 Phonegap 访问文件

当 key 不是字符串时,iOS HTTP Post 方法不起作用

iphone - MPMovies PlayerViewController 在 OS 3.0 上崩溃

ios - CSSMERR_TP_NOT_TRUSTED 错误

ios - UserDefaults 返回比请求的大得多的整数值

swift - FaSTLane 快照 – 空白屏幕截图