[英]What's the difference in Swift between unowned vs weak but implicitly unwrapped?
weak var cat: Cat!
vs对比
unowned var cat: Cat
Just started getting my head around this topic but this one really confuses me, is there any benefits of using weak but implicitly unwrapped variable in normal setting, other than for UI stuff?刚刚开始了解这个话题,但这个话题真的让我感到困惑,除了 UI 内容之外,在正常设置中使用弱但隐式解包的变量有什么好处吗?
unowned var
an initial value that isn't just none
.unowned var
一个不只是none
的初始值。 This is not as meaningful as none
if the initial value is just a placeholder before it gets a "real" value.none
那样有意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.