What's the difference in Swift between unowned vs weak but implicitly unwrapped?

Viewed 208
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?

1 Answers
  1. You can still check an IUO to see if it's nil, even though you don't have to.
  2. You have to give an unowned var an initial value that isn't just none. This is not as meaningful as none if the initial value is just a placeholder before it gets a "real" value.
Related