<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">I don’t get your problem here. If you don’t want to debate the correctness of your code, why are you asking for help or even showing error messages for a code snippet that cannot work?</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">1. Drop the access modifier from the extension itself, because this is only for convenience, which may or may not rule over the members of the extension members. If you’re already explicitly setting the access modifier on the extension members then the convenience access modifier makes no sense.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">2. The code cannot work, because you cannot override `viewDidLoad` on a class that you don’t own, on a subclass of `UISplitViewController` that would be possible.</div> <div><br></div>```<div><div>class MySplitViewController : UISplitViewController {}</div><div><br></div><div>extension MySplitViewController {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>override open func viewDidLoad() {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>super.viewDidLoad()</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>/* ... */</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div></div><div>```<br> <div id="bloop_sign_1505937863196648192" class="bloop_sign"></div> <br><p class="airmail_on">Am 20. September 2017 um 21:41:31, Rick Aurbach via swift-users (<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div></div><div>



<title></title>


<div class="">I am trying to write an extension to a UIKit class,
but am running into a can’t-win situation:</div>
<div class=""><br class=""></div>
<div class="">The code I ‘want’ to write looks like:</div>
<div class=""><br class=""></div>
<div class="">
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 252, 234); min-height: 14px;" class=""><br class=""></div>
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(195, 89, 0); background-color: rgb(255, 252, 234);" class=""><span style="color: #36568a" class="">public</span>
<span style="color: #36568a" class="">extension</span>
UISplitViewController <span style="color: #000000" class="">{</span></div>
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; background-color: rgb(255, 252, 234);" class=""><span style="color: #36568a" class="">override</span>
<span style="color: #36568a" class="">public</span> <span style="color: #36568a" class="">func</span> <span style="text-decoration: underline" class="">v</span>iewDidLoad() {</div>
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168); background-color: rgb(255, 252, 234);" class=""><span style="color: #36568a" class="">super</span><span style="color: #000000" class="">.</span>viewDidLoad<span style="color: #000000" class="">()</span></div>
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168); background-color: rgb(255, 252, 234);" class=""><span style="color: #36568a" class="">if</span>
<span style="color: #c35900" class="">UIDevice</span><span style="color: #000000" class="">.</span>current<span style="color: #000000" class="">.</span>userInterfaceIdiom <span style="color: #000000" class="">== .</span>pad <span style="color: #000000" class="">{</span></div>
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168); background-color: rgb(255, 252, 234);" class="">preferredDisplayMode <span style="color: #000000" class="">= .</span>automatic</div>
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; background-color: rgb(255, 252, 234);" class="">} <span style="color: #36568a" class="">else</span>
{</div>
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168); background-color: rgb(255, 252, 234);" class="">preferredDisplayMode <span style="color: #000000" class="">= .</span>primaryOverlay</div>
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; background-color: rgb(255, 252, 234);" class="">}</div>
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; background-color: rgb(255, 252, 234);" class="">}</div>
<div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; background-color: rgb(255, 252, 234);" class="">}</div>
</div>
<div class=""><br class=""></div>
<div class="">This generates the error message&nbsp;</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">
<div class="">
<div class="">
/Users/rlaurb/Projects/Cooks-Memory/Cooks-Memory/AppDelegate.swift:131:23:
Overriding instance method must be as accessible as the declaration
it overrides</div>
</div>
<div class="">
<div class="">
/Users/rlaurb/Projects/Cooks-Memory/Cooks-Memory/AppDelegate.swift:131:23:
Overridden declaration is here (UIKit.UIViewController)</div>
</div>
<div class=""><br class=""></div>
</blockquote>
But I can’t change the access control of the function to ‘open’,
because I get the warning that the function can’t be “more”
accessible than the extension.
<div class=""><br class=""></div>
<div class="">And I can’t change the extension’s access to ‘open’
because apparently extensions can’t be open.</div>
<div class=""><br class=""></div>
<div class="">Now I don’t want to get into a debate about whether
this code works — it’s just an experiment — but is it even possible
to express this idea?? I.e., is it possible to express this idea
without subclassing?<br class="">
<br class="">
<div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<div style="color: rgb(0, 0, 0); font-family: Arial; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;" class=""><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;">Cheers,</span></div>
<div style="color: rgb(0, 0, 0); font-family: Arial; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;" class=""><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;"><br class=""></span></div>
<div style="color: rgb(0, 0, 0); font-family: Arial; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;" class=""><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;">Rick
Aurbach</span></div>
<div style="color: rgb(0, 0, 0); font-family: Arial; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;" class=""><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;"><br class=""></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>


_______________________________________________<br>swift-users mailing list<br>swift-users@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-users<br></div></div></span></blockquote></div></body></html>