<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=""><div class="">Thanks Joanna Carter, sorry forgot to mention it uses <font color="#0433ff" face="Menlo" class="">generics</font>, so would contain <font color="#0433ff" face="Menlo" class="">associatedtype</font>&nbsp;if <font color="#0433ff" face="Menlo" class="">protocol</font> is used.</div><div class=""><br class=""></div><div class="">Is the below mentioned approach the usual way to hide implementation details or is there a better approach ?</div><div class=""><br class=""></div><div class="">With this approach, I had to pass functions of <font face="Menlo" color="#0433ff" class="">C1</font> as closures into <font color="#0433ff" face="Menlo" class="">Helper</font> functions.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">struct</span><span style="color: #000000" class=""> Helper {} </span>//This is could be a protocol / struct / class</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class="">class<span style="color: #000000" class=""> C1 {</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">private</span> <span style="color: #ba2da2" class="">let</span> helper = <span style="color: #4f8187" class="">Helper</span>()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><br class=""></div><div class=""><br class=""></div><div class="">Please let me know if the question is off-topic and needs to be posted in a separate thread / elsewhere.</div><div class=""><br class=""></div><div class="">Thanks and regards,</div><div class="">Muthu</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 24 Jul 2017, at 5:43 PM, Joanna Carter &lt;<a href="mailto:joanna@carterconsulting.org.uk" class="">joanna@carterconsulting.org.uk</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><blockquote type="cite" class="">Background:<br class="">Just a little background into what I was trying to achieve (I could be wrong):<br class=""><br class="">- I have a set of classes C1, C2, C3 which has a lot of common code<br class=""><br class="">- I would like to build something that can be reused without exposing the implementation details. (I can subclass but would expose the underlying functions, same applies to protocol as well)<br class=""><br class="">- I thought I would build helper class / struct which would contain the common code. I can make the helper a private property so that the functions wouldn’t be exposed to the instances of C1, C2, C3. In order to achieve that I had to pass some functions from C1 into the Helper struct.<br class=""><br class="">Question 2:<br class="">- Is this problem (hiding implementation details) normally tackled using Helper class (or struct) or is there a more better approach ?<br class=""></blockquote><br class="">Usually, as long as the protocol doesn't reference self or have associated types, I would use a protocol as the "abstract" type and then you could implement it in either a class or struct.<br class=""><br class="">Joanna<br class=""><br class="">--<br class="">Joanna Carter<br class="">Carter Consulting<br class=""><br class=""></div></div></blockquote></div><br class=""></body></html>