Questions tagged [unowned-references]

18 questions
1
vote
3 answers

Swift - Capture List self clarification

After reading some articles and developer guide of apple, i'm still confused about Capture List in closure. What does it mean "capture", how does it work behind the scene in terms of unowned self and weak self? how the closure use self without…
r.pul
  • 109
  • 2
  • 9
1
vote
1 answer

When both properties can never be nil what difference does unowned make in terms of allocated memory?

For the following code from the swift programming guide with deinitializers added by me, the resulting debug printout is the same whether the unowned keyword is used or not. The swift programming guide says that using unowned and implicitly…
ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
0
votes
2 answers

Why can't I give an unowned constant an initial value?

class Example {} unowned let first = Example() This produces the error: Attempted to read an unowned reference but object 0x60c000005f20 was already deallocated I'm trying to dig deep into understanding exactly what keyword unowned does.
ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
1
2