What is the meaning of the following syntax in iOS ?. typedef void (^ something) (NSInteger * a);

New for ios. Let me fix it if my understanding is wrong?

typedef void (^someString) (datatype variable_name, datatype variable_name). 

I am mainly from C background.

Is this something like typedef for a pointer function? ..

+6
source share
3 answers

Not exactly a function pointer, but a block. The block is Apple's extension to the C language: it mainly implements lambda functions. It types someString type someString block that returns nothing ( void ) and takes two arguments.

More details here: http://en.wikipedia.org/wiki/Blocks_ (C_language_extension)

and here: http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Blocks/Articles/bxUsing.html

+7
source

This is a block definition. This is a closure form, as implemented in Objective C.

+3
source

it is called a block, you can use it as a function, but it has several privileges, check the Documentation

0
source

Source: https://habr.com/ru/post/914161/


All Articles