<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">In the code below, I’m confused as to wether ‘self’ is owned, unowned or retained inside the ‘bar()’ function. I was assuming that it would always be retained, but I am wondering if that’s correct… Especially the ‘unownedThunk’ example… I don’t recall anything in the Swift book explicitly answering this question.<div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(187, 44, 162);" class="">class</span> Foo {</div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(187, 44, 162);" class="">init</span>() {</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(79, 129, 135);" class="">ownedThunk<span style="color: rgb(0, 0, 0);" class=""> = {</span></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(187, 44, 162);" class="">self</span>.<span style="color: rgb(49, 89, 93);" class="">bar</span>()</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(79, 129, 135);" class="">unownedThunk</span> = { [unowned <span style="color: rgb(187, 44, 162);" class="">self</span>] <span style="color: rgb(187, 44, 162);" class="">in</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(187, 44, 162);" class="">self</span>.<span style="color: rgb(49, 89, 93);" class="">bar</span>()</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(79, 129, 135);" class="">weakThunk</span> = { [weak <span style="color: rgb(187, 44, 162);" class="">self</span>] <span style="color: rgb(187, 44, 162);" class="">in</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(187, 44, 162);" class="">self</span>?.<span style="color: rgb(49, 89, 93);" class="">bar</span>()</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(187, 44, 162);" class="">func</span> bar() {</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(0, 132, 0);" class="">// is 'self' owned/unowned/weak? here?</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(187, 44, 162);" class="">private</span> <span style="color: rgb(187, 44, 162);" class="">var</span> ownedThunk: () -> <span style="color: rgb(112, 61, 170);" class="">Void</span> = { }</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(187, 44, 162);" class="">private</span> <span style="color: rgb(187, 44, 162);" class="">var</span> unownedThunk: () -> <span style="color: rgb(112, 61, 170);" class="">Void</span> = { }</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(187, 44, 162);" class="">private</span> <span style="color: rgb(187, 44, 162);" class="">var</span> weakThunk: () -> <span style="color: rgb(112, 61, 170);" class="">Void</span> = { }</div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><br class=""></div></body></html>