On 12.12.2012, at 12:36, jonat...@mugginsoft.com wrote:

> You could perhaps make this a little less fragile.
> 
>    typedef void (^MyBlockType)(void);
> 
>    // we know this is a block
>    void (^isaBlock)(void) = ^(void) {};
> 
>    MyBlockType aBlock = ^(void) {NSLog(@"I am a block");};
> 
>    id qua = aBlock;
> 
>    if ([qua isKindOfClass:[isaBlock class]]) {
>       ((MyBlockType)qua)();
>    }
> 
> Jonathan


Unfortunately, this doesn't work if the block  `aBlock` has a closure, and 
because of this becomes a different class, so that  ([qua 
isKindOfClass:[isaBlock class]]) evaluates to `No`.

The easiest way would certainly be a reliable statement that the common base 
class for all blocks would be `NSBlock`  (or something else).
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to