Pregunta

The question says it all. Why:

(void)methodWithParamA:(id)paramA paramB:(id)paramB;
[obj methodWithParamA:valA paramB:valB];

and:

void(^ block)(id paramA, id paramB);
block(valA, valB);

I'm not sure I'll necessarily gain anything by learning the answer to this question, but I'm baffled that one language can have so many disparate syntaxes...

¿Fue útil?

Solución

A block is a function, there is no "current instance" (or "current class" for call methods) as with a method.

A block call therefore looks like a function call; a "block" type is a pointer type and follows very closely the syntax for function pointer types; and a block body follows closely the syntax of a function body.

Blocks are supported in C, which has functions but not methods.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top