简体   繁体   English

弱引用IBOutlet - @property(assign)?

[英]Weak referenced IBOutlet — @property (assign)?

Is it a valid approach to reference an IBOutlet weakly by defining a @property as assign in order to prevent a retain-loop? 通过将@property定义为assign以防止保留循环,它是一种有效的方法来弱引用IBOutlet吗? For example, I may want to tell the view what object is its controller; 例如,我可能想告诉视图它的控制器是什么对象; while there are workarounds using nextResponder , it's much easier to simply add an outlet to the view and assign the controller to the view. 虽然有使用nextResponder变通方法,但简单地向视图添加插座并将控制器分配给视图要容易得多。

Sure, you can do that. 当然,你可以做到这一点。 The case you cite is a good example of when you should do it. 你引用的案例是你何时应该这样做的一个很好的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM