Example 1: A controller-"jump-" B controller, false assumption from the B controller callback array to a controller
Implementation: B Controller. h file defines a block parameter,. m file execution block,a controller settings block content
B.h file
Create block blocks @property (nonatomic,copy) void (^block) (Nsarray *array);
B.M File//execute block block
!self.Block? (Space here): Blcok (array); To determine if a block exists, the block is executed, and an array of arrays is passed to xxx (who defines the execution code for block blocks, which is passed to a controller)
a.m. File
B *b=[[b Alloc]init];
b.block=^ (Nsarray *array){
Block execution Code
//...
};
B.M in the presence of block blocks, the executionblcok (array) , and entered the A.M. "Block Execution Code "Processing, where"Block execution Code" OfArrayParameter gets the array b.m passed over
Using the block procedure, be aware of circular references, such as a circular reference to self, using the __weak typeof (self) weakself=self;
Example 2: A controller completes the task, notifies the B controller to perform the next task
A.h File//Creating block blocks@property (nonatomic,copy)void(^Block) (); a.m. File//Executing block blocks!self. Block? (Space here): Blcok ();//to determine if a block exists, the block is executedb.m file a*a=[[A Alloc]init];a.block=^() {//Block Execution Code//perform one-step tasks};//a block block is determined in the A.M., Execution Blcok (), b.m into "Block execution code" is equivalent to receive a pass over the notification signal//using the block procedure, be aware of circular references, such as a circular reference to self, using the __weak typeof (self) weakself=self;
Block implementation agent/notification effect