grillbiff / DragAndDropTableView

A UITableView where cells can be rearranged by drag and drop.
MIT License
55 stars 13 forks source link

.dataSource and .delegates cause retain cycle #2

Closed mnievas closed 10 years ago

mnievas commented 10 years ago

Hi,

I like your implementation but I found a big problem.

I found a retain cycle with your DND table, this methods retain my object (the delegate) and it produce a retain cycle. They shouldn't.

-(void)setDataSource:(id)dataSource and -(void)setDelegate:(id)delegate

When the owner of my object releases it, my object doesn't die. I had to call a method which I called willDealloc, in order to put this code and break the cycle.

_tableView.dataSource = nil; _tableView.delegate = nil;

Regards, Marce.

PD: If the table has more than one section, moving a cell through sections, produce a crash. PD: My project is non-ARC.

grillbiff commented 10 years ago

thanks for the input. The issue should be fixed now, I'll push it to cocoapods as soon as I can. I haven't tested the project for non arc so I'm not sure how it will work. A quickfix is to nil the delegate and datasource in i.e your viewcontrollers viewDidDisappear

_tableView.delegate = nil;
_tableView.dataSource = nil;