@robtimp @jesse_squires Unowned is faster and allows for immutability and nonoptionality. If you don't need weak, don't use it.
-
-
@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. -
@jckarter@chriseidhof so if the object is dead when you access it, swift guarantees a crash whereas objc doesn't? - View other replies
-
@jckarter@chriseidhof sweet. Is it ever possible to make an `assign` reference in swift? Maybe through some Unsafe API? - View other replies
-
@heathborders@chriseidhof There's unowned(unsafe), which is completely unmanaged.
-
-
-
@jckarter@chriseidhof wait, so unowned is in fact strong as long as unown ref is in use? what are tou saying here? -
@krzyzanowskim@chriseidhof Strong refs keep the object alive. Unowned refs keep only the memory alive, but contents is garbage. -
@jckarter@krzyzanowskim@chriseidhof so mark dead just for crashing on access? -
@jckarter@krzyzanowskim@chriseidhof how unowned(unsafe) VS unowned(safe)? unowned defaults to safe or unsafe? - View other replies
-
@an0@krzyzanowskim@chriseidhof unowned is currently synonymous with unowned(safe). -
@jckarter@krzyzanowskim@chriseidhof but what’s the diff between safe and unsafe? -
@an0@krzyzanowskim@chriseidhof unsafe is completely unmanaged, like __unsafe_unretained in ObjC. Dangling access is UB. - Show more
-
-
-
@jckarter@chriseidhof It even get's a bit more complicated: There's unowned(safe) and unowned(unsafe): https://devforums.apple.com/message/987086#987086 … -
@Gernot@chriseidhof, unowned(unsafe) doesn't use any refcounting or checking at all, so you get UB instead of a trap on invalid access.
-
-
@jckarter ah, I see. But a bit of memory stays alive until all unowned references are gone as well.
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
Marcin Krzyzanowski
an0
Gernot