This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum TableSections: Int, CaseIterable { | |
case staticSection, | |
dynamicSection | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func numberOfSections(in tableView: UITableView) -> Int { | |
return TableSections.allCases.count | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum TableSections: Int, CaseIterable { | |
case staticSection, | |
dynamicSection | |
func title() -> String { | |
switch self { | |
case .staticSection: | |
return "Static Cells" | |
case .dynamicSection: | |
return "Dynamic Cells" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | |
return TableSections(rawValue: section)!.title() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { | |
if (indexPath.section == TableSections.staticSection.rawValue) { | |
return nil | |
} else { | |
return indexPath | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBOutlet var puppyCell: UITableViewCell! | |
@IBOutlet var cupcakeCell: UITableViewCell! | |
@IBOutlet var unicornCell: UITableViewCell! | |
@IBOutlet weak var puppyLabel: UILabel! | |
var staticCells: Array<UITableViewCell>! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBOutlet var puppyCell: UITableViewCell! | |
@IBOutlet var cupcakeCell: UITableViewCell! | |
@IBOutlet var unicornCell: UITableViewCell! | |
@IBOutlet weak var puppyLabel: UILabel! | |
var staticCells: Array<UITableViewCell>! | |
var dynamicContent = ["One", "Two", "Three", "Four"] | |
let dynamicCellIdentifier = "Dynamic" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
if (section == TableSections.dynamicSection.rawValue) { | |
return dynamicContent.count | |
} else { | |
return staticCells.count | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
if (indexPath.section == TableSections.staticSection.rawValue) { | |
return staticCells[indexPath.row] | |
} else { | |
let cell = tableView.dequeueReusableCell(withIdentifier: dynamicCellIdentifier, for: indexPath) | |
cell.textLabel?.text = dynamicContent[indexPath.row] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
if (section == TableSections.dynamicSection.rawValue) { | |
return dynamicContent.count | |
} else { | |
return staticCells.count | |
} | |
} |
OlderNewer