Int ivisen = 1000;-(void) viewdidload {[Super viewdidload]; // do any additional setup after loading the view, typically from a nib. // int code block int Mutl = 7; int (^ visenblock) (INT) = ^ (INT num) {return num * Mutl ;}; nslog (@ "% d ", visenblock (4); // nsstring code block void (^ visenprintstring) (nsstring * Str) = ^ (nsstring * Str) {nslog (@ "Print: % @", str) ;}; visenprintstring (@ "aaaa"); // The code is used in string array sorting nsarray * stringarra Y = [nsarray arraywithobjects: @ "ABC 1", @ "ABC 21", @ "ABC 12", @ "ABC 13", @ "ABC 05", nil]; nscomparator visensortblock = ^ (ID string1, Id string2) {return [string1 compare: string2] ;}; nsarray * sortarray = [stringarray visibility: visensortblock]; nslog (@ "sortarray: % @ ", sortarray); // recursive call of the code block // The code block must be a global or static variable, in this way, when the program starts, the code block variable is initialized. You can recursively call static void (^ const visenrecursionb Lock) (INT) = ^ (int I) {if (I> 0) {nslog (@ "Num: % d", I ); visenrecursionblock (I-1) ;};}; visenrecursionblock (3); // use the global variable void (^ visenvariablesblock) (void) = ^ (void) {ivisen + +; nslog (@ "% d", ivisen) ;}; visenvariablesblock (); // use local variables in the code block // change local variables in the code block. Compilation fails. How can I change local variables in a code block? Add the keyword __block _ block int ivisena = 1000 before the local variable; void (^ visenvariablesblockb) (void) = ^ (void) {ivisena ++; nslog (@ "Local: % d", ivisena) ;}; visenvariablesblockb ();}