(I have already referred this StackOverflow post, however did not find what I was looking for)
I have a requirement to show ads in between cells of a UITableView
.
The image above is used only for representational purposes, and does not show the actual design/data used by the app I am working with.
The normal cells of the UITableView
come from a Core Data
fetch request via NSFetchedResultsController
using fetchController.object(at: indexPath)
, whereas the ad cells come from a different data source altogether.
- Since the ads need to be shown in between the actual table view cells, it messes up the
indexPath
used byNSFetchedResultsController
to retrieve the object fromCore Data
fetch request. - Also the user has the option to delete any of the actual cells (non-ad cells) from the
UITableView
, which can in-turn change theindexPath
of the cells. - There can be variable number of ads shown in the cells, for now assume it to be a constant
c
.
Please let me know if there is a way to handle all these edge cases efficiently, preferably without changing the indexPath
object used in fetchController.object(at: indexPath)
.