MLeaksFinder使用

上两周github出了点问题,不能clone和提交代码,今天终于有空闲下来试试MLeaksFinder

通过pod安装MLeaksFinder,然后我们本地造一个循环引用

//使用最常见的tableView来做吧

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ReasonCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([ReasonCell class])];
    cell.indexPath = indexPath;
    cell.didTouch = ^(NSIndexPath*indexPath){
        [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
        NSLog(@"======= %@ =======",indexPath);
    };
    return cell;
}

我们传入一个路径打印,重写cell中的点击方法

// cell中的属性
typedef void(^DidTouch)(NSIndexPath * indexPath);
@interface ReasonCell : UITableViewCell
@property (nonatomic,copy)DidTouch didTouch;
@property (nonatomic,strong)NSIndexPath * indexPath;
@end
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    !self.didTouch?:self.didTouch(self.indexPath);
}

我们从homeViewController push 到 reasonViewController 后返回,等一小下就能看到提示了

image description

实验代码放到了github上

祝大家使用愉快!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容