@robtimp @jesse_squires Unowned is faster and allows for immutability and nonoptionality. If you don't need weak, don't use it.
-
-
@jckarter ah, so the second refcount tracks how many things refer to that unowned object? -
@chriseidhof Yeah, so we can check whether the object is still alive before strong-retaining it again. - View other replies
-
@jckarter wait, so as long as there's an unowned ref, memory isn't freed? How does unowned prevent ref cycles then? -
@jckarter when A refers B strongly, and B refers A unowned, it still creates a cycle? Because A only is released after unowned releases? - View other replies
-
@chriseidhof The object is destroyed and gives up all its resources when the last strong reference is released. - View other replies
-
@chriseidhof The memory for the instance is still allocated but left in a zombie state. - View other replies
-
@jckarter@chriseidhof just to clarify: does `unowned` behave basically like `assign` in objc? -
@heathborders@chriseidhof The property doesn't keep the object alive, but the runtime still validates access to the dead object. - Show more
-
-
@chriseidhof But for long lived refs like delegates or outlets, weak is still more appropriate. It'd be unacceptable to delay release. -
@chriseidhof Since unowned is intended primarily as circularity breaker, refs will go away soon enough in practice. -
-
@jckarter@chriseidhof I thought unowned are just dangling pointers, hence unsafe. You say they are also managed? -
-
@chriseidhof@jckarter it should crash if there are no other strong ref. By management I mean ref counting. Why it needs ref counting? - View other replies
-
@an0@chriseidhof Reliably crashing on dangling references requires some bookkeeping about references.
-
-
-
@jckarter@chriseidhof unowned actually keeps the memory alive? But deinit runs after the last owning ref drops so it’s just zombie right? -
@jckarter@chriseidhof already answered sorry.
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Joe Groff
Chris Eidhof
Heath Borders
an0
Matthew Johnson