DenTelezhkin / DTTableViewManager

Protocol-oriented UITableView management, powered by generics and associated types.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When adding an item within whenSelected function, configureCell doesn't get called

davidevincenzi opened this issue · comments

Hello!
If you add a new item on your memoryStorage within a whenSelected function, configureCell for the new cell doesn't get called.

For example:

manager.registerCellClass(RightDetailTableViewCell.self) { [weak self] (cell, model, indexPath) -> Void in let someObject = SomeObject() try! manager.memoryStorage.addItem(someObject, toSection: 0) }

manager.configureCell(SomeCell.self) { (cell, model, indexPath) -> Void in print("This doesn't get called") }

I discovered that calling performSelectorOnMainThread works, which is strange because what is inside the whenSelected function is already executed on the main thread.

manager.registerCellClass(RightDetailTableViewCell.self) { [weak self] (cell, model, indexPath) -> Void in self?.performSelectorOnMainThread("addItem", withObject: userInfo, waitUntilDone: true) }

func addItem() { let someObject = SomeObject() try! manager.memoryStorage.addItem(someObject, toSection: 0) }

Thanks

Mmm, that's strange, i tried making this in example project, and everything works correctly, configureCell does get called.

Can you provide example project or some more information to reproduce this behaviour?

Sure, I'll try to strip down a sample project with the issue. Just give me a day or two and I'll set it up.
Maybe there's a particular condition for it to happen.
I'll update asap.

Sorry Denis, I was working with an older version of the library.
The last one doesn't have the problem.
Thanks

No problem 🍺