美文网首页
MLeaksFinder使用

MLeaksFinder使用

作者: 焚琴煮鹤de我 | 来源:发表于2016-10-27 18:22 被阅读225次

上两周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上

祝大家使用愉快!

相关文章

网友评论

      本文标题:MLeaksFinder使用

      本文链接:https://www.haomeiwen.com/subject/eirsuttx.html