<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=""><br class=""><div><blockquote type="cite" class=""><div class="">Le 25 févr. 2016 à 20:28, Matthew Johnson <<a href="mailto:matthew@anandabits.com" class="">matthew@anandabits.com</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 25, 2016, at 1:23 PM, Jean-Daniel Dupas <<a href="mailto:mailing@xenonium.com" class="">mailing@xenonium.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">Le 25 févr. 2016 à 20:19, Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> a écrit :<br class=""><br class=""><br class=""><br class="">Sent from my iPad<br class=""><br class=""><blockquote type="cite" class="">On Feb 25, 2016, at 1:17 PM, Jean-Daniel Dupas via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">Le 25 févr. 2016 à 16:47, Jeremy Pereira via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> a écrit :<br class=""><br class=""><br class=""><blockquote type="cite" class="">On 17 Feb 2016, at 22:26, Kyle Sherman via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">Thanks for the replies.<br class=""><br class="">Kenny: After thinking about it more, discussing with Peter, and looking Haravikk’s comments, I think the best thing would be for this to be a warning as suggested. I respectfully disagree that as a library creator you would not be able to know that a call to super should be required.<br class=""></blockquote><br class="">I disagree. You can’t possibly know all the use-cases in which your class might be subclassed.<span class="Apple-converted-space"> </span><br class=""><br class="">In particular, it is absurd to enforce having the call to super as the first or last line of the method. That would stop me doing things like this:<br class=""><br class="">override func viewDidLoad()<br class="">{<br class=""> print(“About to run super.viewDidLoad()”)<br class=""> super.viewDidLoad()<br class=""> print(“Finished super.viewDidLoad()”)<br class="">}<br class=""><br class="">Then there’s the perfectly reasonable case like this:<br class=""><br class="">override func viewDidLoad()<br class="">{<br class=""> functionThatCallsSuperViewDidLoad()<br class="">}<br class=""><br class="">Why shouldn’t I be allowed to do that?<br class=""></blockquote><br class="">+1 with your concern. I’d be curious to see a single real world use case where enforcing first or last is required.<br class=""></blockquote><br class="">I posted several examples from Apple frameworks in an old thread about this. You might want to look for that message in the archives.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">And not a single one has a strong requirement about prohibiting code to be call before or after the super class implementation.</span></div></blockquote><br class=""></div><div class="">It depends what you mean by “strong”. Sure, a log statement won’t make much difference. But the examples I gave do have semantic requirements that super should either go first or last in performing real work to be done by the method.</div></div></div></blockquote><br class=""></div><div>For instance:</div><div><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">// If you override this method, you must call super first to get the invalidation context object to return. After getting this object, set any custom properties and return it.
func invalidationContextForBoundsChange(_ newBounds: CGRect) -> UICollectionViewLayoutInvalidationContext</pre><div class=""><br class=""></div><div class="">Why must I call super first ? Why can’t I don’t a bunch of things that are related to my subclass first ?</div><div class=""><br class=""></div><div class="">How am I supposed to do if I want to compute a new bound to pass to super instead of forwarding it naively.</div><div class=""><br class=""></div><div class="">ditto for </div><div class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">// call super first to retrieve the item’s existing attributes and then make your changes to the returned structure.
layoutAttributesForInteractivelyMovingItemAtIndexPath(_ indexPath: NSIndexPath, withTargetPosition position: CGPoint) -> UICollectionViewLayoutAttributes</pre><div class="">Why would you prevent a subclass to compute an other indexPath or target position before calling super ?</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><br class=""></body></html>