Xcode is sending me the error "fatal error: init(coder:) has not been implemented error" despite being implemented. I don't know where the problem is.
final class newTableViewController: UITableViewController {
@IBOutlet var inputFormTableView: UITableView!
let form: Form
let note = Note(name: "")
init(form: Form) {
self.form = form
super.init(style: .grouped)
}
convenience init(note: Note) {
let form = Form(sections: [
FormSection(items: [
TextInputFormItem(text: note.name,
placeholder: "Add title",
didChange: { _ in print("hello")})
])
])
self.init(form: form)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
inputFormTableView.rowHeight = 44
inputFormTableView.register(TextInputTableViewCell.self, forCellReuseIdentifier: ReuseIdentifiers.textInput.rawValue)
let new = newTableViewController(note: note)
print(new.note.name)
}
private enum ReuseIdentifiers: String {
case textInput
}
// MARK: - Table view data source
private func model(at indexPath: IndexPath) -> FormItem {
return form.sections[indexPath.section].items[indexPath.item]
}
override func numberOfSections(in tableView: UITableView) -> Int {
return form.sections.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return form.sections[section].items.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let object = model(at: indexPath)
if let textRow = object as? TextInputFormItem {
let cell = tableView.dequeueReusableCell(withIdentifier: ReuseIdentifiers.textInput.rawValue, for: indexPath) as! TextInputTableViewCell
cell.configure(for: textRow)
return cell
}
else {
fatalError("Unknown model \(object).")
}
}
}
I am trying to make UITableView act like an input form. For doing this, I am following this tutoriel : https://augmentedcode.io/2018/11/04/text-input-in-uitableview/. Everything works in the sample project but not mine.
init?(coder: NSCoder)is not implemented. The code to initializeformand thesupercall is missing.