Swift UITableView Show Different Cell Every 10th Cell

Viewed 1692

I'm trying to show a different cell after every 10 cells using two arrays: "ads" and "requests" I want my TableView to look like this:

"Request"
"Request"
"Request"
"Request"
"Request"
"Request"
"Request"
"Request"
"Request"
"Request"
"Ad"
"Request"
"Request"
...

I know how to do an ad but not how to order the cells like this using two arrays. Not at all :/ Any suggestions how to achieve that? Thanks in advance!

EDIT:

func loadAds()
    {
        Api.adApi.observeAds
        {
            (ad) in
            self.list = self.requests
            for i in stride(from: self.adInterval, to: self.requests.count, by: self.adInterval).reversed()
            {
                // not getting executed
                print("test1")
                self.list.insert(ad, at: i)
            }
            // getting executed
            print("test2")
        }
    }
3 Answers
Related