How does typedef-ing a block works

See Declaring a Block Reference in “Blocks Programming Topics”:

Block variables hold references to blocks. You declare them using
syntax similar to that you use to declare a pointer to a function,
except that you use ^ instead of *.

So

 typedef void (^myBlock) (int a);

defines a the type of a block using the same syntax as

 typedef void (*myFunc) (int a);

declares a function pointer.

See e.g. Understanding typedefs for function pointers in C for more information about function pointers.

Leave a Comment