<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="">Hi guys,<div class="">My idea is simple, put an access level control token to the setter of a var</div><div class=""><br class=""></div><div class="">Right now, we are likely to do something like this in order to hide the setter:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">fileprivate</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">var</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> _timestamp: </span><span style="font-variant-ligatures: no-common-ligatures;" class="">Date</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures;" class="">Date</span><span style="font-variant-ligatures: no-common-ligatures;" class="">()</span></div><p style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo; min-height: 24px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">public</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">var</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> timestamp: </span><span style="font-variant-ligatures: no-common-ligatures;" class="">Date</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> {</span></div><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">return</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">self</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures;" class="">_timestamp</span></div><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div></div><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">The idea is to do it without using another var, like this:</span></div><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Menlo; font-size: 20px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">public</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures;" class="">var</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;timestamp:&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures;" class="">Date</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;{</span></div><div style="font-family: Menlo; font-size: 20px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>get {&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures;" class="">return</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures;" class="">self</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures;" class="">_timestamp }</span></div><div style="font-family: Menlo; font-size: 20px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>fileprivate set(newValue) { _timestamp = newValue }</span></div><div style="font-family: Menlo; font-size: 20px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div style="font-family: Menlo; font-size: 20px; margin: 0px; line-height: normal;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class="">In this way the setter will be available&nbsp;“locally” in the file but it will not be accessible from outside.</div><div style="margin: 0px; line-height: normal;" class="">The only problem that I can see is how to reference the var itself? As you can see I used &nbsp;“_timestamp” like Objective-C, but there should be another way to do reference it.</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Cheers,</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Pascal</div><div style="font-family: Menlo; font-size: 20px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div></div><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></span></div><div style="margin: 0px; font-size: 20px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></span></div><div class=""><br class=""></div></body></html>