Для последовательностей:
["a", "b", "c"], ["a", "b", "c"], ["a", "b","c"] и т. д.
или в обратном порядке
["a", "b", "c"], ["c", "b", "a"], ["a "," b "," c "] и т. д.
let repeateCount = 4
let reverse = false
let array = ["a","b","c"]
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count * repeateCount
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
var index = indexPath.row % array.count
if reverse {
if (indexPath.row / array.count) % 2 != 0 { // odd
index = array.count - index - 1
}
}
let someWord = array[index]
return cell
}