<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">You can implement an @objc protocol with an optional requirement, and make NSObject conform to it.<div class=""><br class=""></div><div class="">Slava<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 24, 2017, at 4:05 PM, Charles Srstka <<a href="mailto:cocoadev@charlessoft.com" class="">cocoadev@charlessoft.com</a>> wrote:</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; line-break: after-white-space;" class=""><blockquote type="cite" class="">On Oct 24, 2017, at 5:02 PM, Slava Pestov via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""></blockquote><div class=""><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Thoughts? Does anyone actually rely on this feature, instead of just stumbling on it by accident once in a while?</span></div></blockquote></div><br class=""><div class="">The main thing I can think of off the top of my head is getting the tag from the sender in an IBAction:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">@IBAction</span> <span style="color: #ba2da2" class="">private</span> <span style="color: #ba2da2" class="">func</span> someAction(<span style="color: #ba2da2" class="">_</span> sender: <span style="color: #ba2da2" class="">Any</span>?) {</div></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><div style="font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""> <span style="color: #ba2da2" class="">guard</span> <span style="color: #ba2da2" class="">let</span> tag = (sender <span style="color: #ba2da2" class="">as</span> <span style="color: #703daa" class="">AnyObject</span>?)?.tag <span style="color: #ba2da2" class="">as</span> <span style="color: #703daa" class="">Int</span>? <span style="color: #ba2da2" class="">else</span> { <span style="color: #ba2da2" class="">return</span> }</div><div style="font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""> ...</div><div style="font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">}</div><div style="font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Unfortunately given how many unrelated Cocoa objects there are that implement -tag, it’s not really practical to implement this without the AnyObject dispatch. If a TagContaining protocol could be introduced and all the objects that implement -tag could be made to conform to it, then that would work around the problem (I believe I pitched this at some point long ago, but without catching any interest).</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Charles</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div></div></div></div></blockquote></div><br class=""></div></body></html>