<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="">Hello Swift Users,<div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>This is a Swift3 newbie question that I’ve not found a solution to. Has there been any consensus reached on an equivalent approach to the AppKit class&nbsp;<font face="Lucida Grande" class="">NSInvocation ? Here’s a simple objC example.</font></div><div class=""><font face="Lucida Grande" class=""><br class=""></font></div><div class=""><font face="Lucida Grande" class=""><br class=""></font></div><div class=""><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">-(</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">NSInteger</span><span style="font-variant-ligatures: no-common-ligatures" class="">)totalCount</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">NSInteger</span><span style="font-variant-ligatures: no-common-ligatures" class=""> totalCount = -1;</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; if</span><span style="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" class=""> ([</span><span style="color: rgb(126, 70, 0); font-variant-ligatures: no-common-ligatures;" class="">self</span><span style="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="color: rgb(52, 149, 175); font-variant-ligatures: no-common-ligatures;" class="">representedObject</span><span style="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="color: rgb(52, 149, 175); font-variant-ligatures: no-common-ligatures;" class="">respondsToSelector</span><span style="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" class="">:</span><span style="color: rgb(126, 70, 0); font-variant-ligatures: no-common-ligatures;" class="">@selector</span><span style="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" class="">(totalCount)])</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #7e4600" class="">SEL</span><span style="font-variant-ligatures: no-common-ligatures" class=""> selector = </span><span style="font-variant-ligatures: no-common-ligatures; color: #7e4600" class="">@selector</span><span style="font-variant-ligatures: no-common-ligatures" class="">(totalCount);</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">NSMethodSignature</span><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; *aSignature =&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures;" class="">[[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(126, 70, 0);" class="">self</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="color: rgb(52, 149, 175); font-variant-ligatures: no-common-ligatures;" class="">representedObject</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="color: rgb(52, 149, 175); font-variant-ligatures: no-common-ligatures;" class="">class</span><span style="font-variant-ligatures: no-common-ligatures;" class="">] </span><span style="color: rgb(52, 149, 175); font-variant-ligatures: no-common-ligatures;" class="">instanceMethodSignatureForSelector</span><span style="font-variant-ligatures: no-common-ligatures;" class="">:selector];</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #7e4600" class="">if</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (aSignature != </span><span style="font-variant-ligatures: no-common-ligatures; color: #7e4600" class="">nil</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande'; color: rgb(52, 149, 175);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">NSInvocation</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; *anInvocation = [</span><span style="font-variant-ligatures: no-common-ligatures" class="">NSInvocation</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">invocationWithMethodSignature</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">:aSignature];</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [anInvocation </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">setSelector</span><span style="font-variant-ligatures: no-common-ligatures" class="">:selector];</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [anInvocation </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">setTarget</span><span style="font-variant-ligatures: no-common-ligatures" class="">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #7e4600" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">representedObject</span><span style="font-variant-ligatures: no-common-ligatures" class="">];</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [anInvocation </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">invoke</span><span style="font-variant-ligatures: no-common-ligatures" class="">];</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [anInvocation </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">getReturnValue</span><span style="font-variant-ligatures: no-common-ligatures" class="">:&amp;totalCount];</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #7e4600" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> totalCount;</span></div><div style="margin: 0px; line-height: normal; font-family: 'Lucida Grande';" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Thanks and regards,</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">RFM</span></div></body></html>