also known as closures or lambdas
block syntax:
1. ^
2. ( parameterType parameterName )
3. { code to be executed }
ex:
// declare a block variable test
void (^test)(void);
// define block's code
test = ^ { NSLog("test"); };
// execute block
test();
ex:
void (^test)(void) = ^ { NSLog("test"); };
沒有留言:
張貼留言