<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Here is another option. Attached is a playground I was messing around with. There are some weird bugs I was noticing, but don’t quite know if they are important enough to submit (comment out line 54 to see).<div class=""><br class=""></div><div class="">I actually like using the $0 so as to allow access to self if using within another type (ex: view controller code below).</div><div class=""><br class=""></div><div class="">Please respond with any potential issues with the code I have written.</div><div class=""><br class=""></div><div class="">- Jo</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">protocol</span> ClosureInit { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>() }</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>ClosureInit<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>init<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>@noescape<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> b: </span>inout<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Void</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">) { </span>self<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>init<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(); b(&</span>self<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">) }</span></div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class="">}</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">struct</span> Person: <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ClosureInit</span> {</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">enum</span> GenderType: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> Male, Female }</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> age: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> gender: <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">GenderType</span>?</div><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> name: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span>?</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class="">}</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> me = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Person</span> {</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">name</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Jo"</span></div><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">age</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">32</span></div><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">gender</span> = .<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Male</span></div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class="">}</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">me</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">age</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>// 32</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Array</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span>ClosureInit<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> { }</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> randomIntArray = [<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>] {</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">for</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">_</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span> <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>...<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">10</span> {</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal; color: rgb(61, 29, 129);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> $0.</span>append<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>arc4random_uniform<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">100</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)))</span></div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> }</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class="">}</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class="">randomIntArray</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> personArray = [<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Person</span>] {</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">for</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">_</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span> <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>...<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">8</span> {</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">append</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Person</span> {</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">age</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">arc4random_uniform</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">100</span>))</div><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">gender</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">arc4random_uniform</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">100</span>)) % <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span> == <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span> ? .<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Male</span> : .<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Female</span> <span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// comment this line out to see error</span></div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> })</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> }</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">}</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class="">personArray</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span>ClosureInit<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> { }</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span> ViewController: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIViewController</span> {</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">override</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> viewDidLoad() {</div><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">super</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">viewDidLoad</span>()</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UILabel</span> {</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">text</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"This is Awesome!"</span></div><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">textColor</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">cyanColor</span>()</div><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">frame</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGRect</span>(x: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">20</span>, y: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">20</span>, width: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">view</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">frame</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">width</span> - <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">40</span>, height: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">40</span>)</div><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">view</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">addSubview</span>($0)</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> }</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">view</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">addSubview</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIButton</span> {</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">setTitle</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Submit"</span>, forState: .Normal)</div><div style="margin: 0px; line-height: normal;" class=""> $0.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">frame</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGRect</span>(x: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">20</span>, y: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">60</span>, width: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">view</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">frame</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">width</span> - <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">40</span>, height: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">40</span>)</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> })</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""> }</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class="">}</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> vc = </span>ViewController<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(61, 29, 129);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">vc</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>loadViewIfNeeded<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">vc</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>view<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>subviews</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""></div></div></div></div></div></body></html>