/*1. Define the BLOCK variable: return value type (^block variable name) (parameter type 1, parameter Type 2, ...); 2. Assign the block variable The block variable name = ^ (parameter type 1 parameter name 1, ...) { }; *//*1. Set animation Properties 2. Start the animation 3. Animation execution Complete Block1 = ^{encapsulates what you want to do before the animation starts executing}; Block2 = ^{encapsulates what you want to do after the animation is executed}; */#import<Foundation/Foundation.h>//typedef int MYINT;//Myblock is actually the new data type nametypedefint(^myblock) (int,int);/*need to Master: 1. Define the block variable 2. Assigning block variables to 3.type and block applications*/intMainintargcConst Char*argv[]) {Myblock minus= ^(intAintb) {returnAb; }; intD = Minus (Ten,5); NSLog (@"D ID%d", D); Myblock sum= ^(intV1,intv2) { returnV1 +v2; }; intE = SUM (Ten, One); NSLog (@"E is%d", E); /*Int (^minusblock) (int, int) = ^ (int A, int.) {return a-B; }; Minusblock (10, 5); Int (^averageblock) (int, int) = ^ (int a, int b) {return (A + b)/2; };*/ return 0;}voidtest2 () {intA =Ten; __blockintb =Ten; //The default local variables cannot be modified inside the block//define a block variable void(^block) () = ^{ //a = one;b = One; NSLog (@"b=%d", B); }; Block (); Block (); Block ();}voidTest () {//the Void:block on the left has no return value//rightmost (): No parameters//The symbol of the middle (^) block, cannot be less void(^myblock) () = ^{ intA = One; intb = One; NSLog (@"a=%d, b=%d", A, b); }; Myblock (); //define a block variable with a variable name of Sumblock//The return value of the leftmost int:block is of type int//The rightmost (int, int) block accepts two parameters of type int int(^sumblock) (int,int); Sumblock= ^(intV1,intv2) { returnV1 +v2; }; intsum = Sumblock (Ten, One); NSLog (@"sum=%d", sum);}