<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>mikeash.com pyblog/friday-qa-2011-10-28-generic-block-proxying.html comments</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-10-28-generic-block-proxying.html#comments</link><description>mikeash.com Recent Comments</description><lastBuildDate>Sun, 10 May 2026 04:24:18 GMT</lastBuildDate><generator>PyRSS2Gen-1.0.0</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Leo Natan - 2019-09-25 11:10:42</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-10-28-generic-block-proxying.html#comments</link><description>For future reference, Core Foundation includes a function which achieves something similar:
&lt;br /&gt;
&lt;br /&gt;extern id __NSMakeSpecialForwardingCaptureBlock(const char *signature, void (^handler)(NSInvocation *inv));
&lt;br /&gt;
&lt;br /&gt;Signature of a block can be obtained using 
&lt;br /&gt;
&lt;br /&gt;extern const char* _Block_signature(id block);
&lt;br /&gt;
&lt;br /&gt;or from a protocol using
&lt;br /&gt;
&lt;br /&gt;extern const char* _protocol_getMethodTypeEncoding(Protocol* protocol, SEL name, BOOL isRequiredMethod, BOOL isInstanceMethod);
&lt;br /&gt;
&lt;br /&gt;The resulting block object can be passed as a normal block, and once invoked, the provided callback will be called with the invocation object.</description><guid isPermaLink="true">f6339946c4c9791ed9a1e01042818569</guid><pubDate>Wed, 25 Sep 2019 11:10:42 GMT</pubDate></item><item><title>R.George - 2013-03-22 02:01:27</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-10-28-generic-block-proxying.html#comments</link><description>Reading long after the fact here... I was playing around with something related (trying to synthesize property accessors at runtime), and noticed that the digging up of the forwarding IMP: [self methodForSelector: @selector(thisDoesNotExistOrAtLeastItReallyShouldnt)] can be shortened to _objc_msgForward. I could hardly believe it, but it's actually public, and declared in objc/message.h along with _objc_msgForward_stret.
&lt;br /&gt;
&lt;br /&gt;As far as I can tell, the only current portable way to tell whether any given method uses stret vs. normal calling conventions is to search -[NSMethodSignature debugDescription] for the magic string. No lie. Enhancement request has been filed.</description><guid isPermaLink="true">073590390ed5b40ff947003e736e0c35</guid><pubDate>Fri, 22 Mar 2013 02:01:27 GMT</pubDate></item></channel></rss>
