DenTelezhkin / DTTableViewManager

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting/Updating section header for specific section

EngrAhsanAli opened this issue · comments

Hi!

I am fetching data from web API, and appending in a specific tableView section. So I have the scenario when I get results for section 1 before for section 0.

How to set/update setSectionHeaderModels for specific index. I am considering updating section title (data) after getting response from the web api.

Hi!

You should probably store section header models in your view model or view controller depending on your architecture. Then, update headerModelProvider on MemoryStorage:

manager.memoryStorage.headerModelProvider = { index in return <headerModel by index>}

Then call reloadData:

tableView.reloadData()

This is needed, because UITableView does not have explicit API for updating only headers/footers.

Also, consider updating data when you've already received both API responses, this may lead to more consistent behavior and UI.