What is the syntax to declare a C function that returns an Objective-C block? Is it possible?
I thought it should be something like
(void (^)(void)) myFunctionReturningABlock();
but that won't compile.
The syntax for your function is slightly incorrect.
As I understand it, you should define your block as a type which you can use as the return type for your function like this:
typedef void(^MyAwesomeBlock)(void);
MyAwesomeBlock blockFunction()
{
MyAwesomeBlock block = ^{
//some code;
};
return block;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With