iOS block callback value, callback event,
Directly on the code
In FIRSTVC inside the TableView click Method, inside click Jump to another NEXTVC, and then return back after the FIRSTVC callback value
-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{Nextviewcontroller*next=[[Nextviewcontroller alloc]init]; __block Nextviewcontroller*_next =next;//Prevent circular references, so write __weaktypeof(self) _self =Self ; Next.back=^(intindex) {NSLog (@"--%d", index);//The value of the callback is printed out _next.data=@"ASDASDASD";//Pass aNSLog (@"index===%d", index); [_self Openalter]; }; [Self presentviewcontroller:next animated:yes completion:null];}
Define block inside NEXTVC, as a @property value
void (^callback) (int index); @interface nextviewcontroller:uiviewcontroller@property (nonatomic,assign) callBack back;
The Viewdidload method in NEXTVC calls this block:
Back(ten);
When clicked back, the value is recalled to the block method inside the FIRSTVC.
To accomplish this, block is an anonymous function, which is simpler than delegate, with values, callbacks,
Learn from http://my.oschina.net/leejan97/blog/268536