block 用法

2016.1.13

1.(1)或(2)

(1)__weak typeof(self) weakSelf = self;

(2)__weak UIViewController *weakSelf = self;

2016.3.17

在.h 中

typedef void (^MyExerciseBlock) (NSString *string,CGFloat height); // 定义 block ---无返回值 2个参数

@interface SenceTableCell : UITableViewCell<UITextViewDelegate>

 

@property (nonatomic,copy)      MyExerciseBlock cellBlock;// 声明block 

 - (void)updateCellData:(NSString *)string heitht:(CGFloat )height img:(NSString*)img;// 刷新cell 

@end

 .m  调用的时候

  _MyExerciseBlock(_titleView.text,_titleHeight);

 

其它地方实现

xxx.MyExerciseBlock = ^(string,heitht){

 

    //实现的功能


};

 

原文地址:https://www.cnblogs.com/tom2015010203/p/5127943.html