参考文章:http://www.jianshu.com/p/b33e5989a352
mvc分离自定义的cell里使用strong修饰,会导致controller无法dealloc,反复进页面占用内存不断增大;使用assign修饰,点击按钮会崩溃。
正确的用法是使用strong,在controller中使用weakSelf;
eg
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = @"HistoryTableViewCell";
HistoryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[[NSBundle mainBundle] loadNibNamed:identifier owner:nil options:nil] firstObject];
}
cell.model = self.datalist[indexPath.row];
__weak typeof(self) weakSelf = self;
cell.block = ^(UIButton *btn) {
[weakSelf dealWithBtn:btn];
};
return cell;
}