Edited
You need to have two sections and manage them differently on the cellForRowAtIndexPath
datasource method.
First
Add two sections on the numberOfSections
datasource method
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
Second
Manage the numberOfCell
datasource method
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0:
return yourArray.count
case 1:
return 1
default:
return 0
}
}
Third
Manage each sections accordingly. Based on what you said, you want the first section to be dymanic and the second static.
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section {
// your dynamic cells
case 0:
let dynamicCell = tableView.dequeueReusableCell(withIdentifier: "dynamicCell") != nil ? tableView.dequeueReusableCell(withIdentifier: "dynamicCell")! : UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "dynamicCell")
dynamicCell.textLabel?.text = yourArray[indexPath.row]
return dynamicCell
// your static cell
case 1:
guard let staticCell = tableView.dequeueReusableCell(withIdentifier: "staticCell") else {
let staticCell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "staticCell")
staticCell.textLabel?.text = "Static"
return staticCell
}
staticCell.textLabel?.text = "Static"
return staticCell
default:
return UITableViewCell()
}
}
Hope this helps.
Also, there might some minor mistakes with my datasource methods name