<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=""><blockquote type="cite" class="">On Feb 6, 2016, at 2:47 PM, Jean-Daniel Dupas via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></blockquote><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div 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="">Wouldn’t it be possible to simply drop the copyWithZone: method that is deprecated for some times now (To quote the doc: Zones are ignored on iOS and 64-bit runtime on OS X. You should not use zones in current development).</span></div></blockquote></div><br class=""><div class="">Unfortunately, the frameworks often call the copyWithZone() method directly on objects that support NSCopying, rather than copy(). For example, @property (copy) properties in Objective-C, and @NSCopying properties in Swift behave this way:</div><div class=""><br class=""></div><div class="">--</div><div class=""><br class=""></div><div class=""><div class="">import Foundation</div><div class=""><br class=""></div><div class="">class Foo: NSObject, NSCopying {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>override func copy() -&gt; AnyObject {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>print("copy() called")</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>return Foo()</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func copyWithZone(zone: NSZone) -&gt; AnyObject {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>print("copyWithZone() called")</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>return Foo()</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class="">}</div><div class=""><br class=""></div><div class="">class Bar {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>@NSCopying var foo: Foo = Foo()</div><div class="">}</div><div class=""><br class=""></div><div class="">let bar = Bar()</div><div class=""><br class=""></div><div class="">bar.foo = Foo()</div></div><div class=""><br class=""></div><div class="">outputs:</div><div class=""><br class=""></div><div class=""><div class="">copyWithZone() called</div></div><div class=""><br class=""></div><div class="">--</div><div class=""><br class=""></div><div class="">Even if this could be changed, and the frameworks completely audited to replace every call of copyWithZone() with a call to copy(), the fact that copyWithZone() has always been part of the API contract means that third-party libraries and frameworks could be calling it, which subsequently means that they would break if copyWithZone() were to go away. Calling copyWithZone() directly isn’t completely unheard of, actually; if an object is implementing its own copyWithZone() method and one of its properties conforms to NSCopying, it may well call copyWithZone() to do the copy, because it’s already got this zone pointer right here, and hey, why not. Add the fact that this was actually correct practice way back in the day when zones were still in use, and I’m sure there’s at least some amount of code like this out there.</div><div class=""><br class=""></div><div class="">One thing you could do, of course, is use compiler magic to turn override func copy() into func copyWithZone(_), but I’m not sure it’s worth it just for this.</div><div class=""><br class=""></div><div class="">Charles</div><div class=""><br class=""></div></body></html>