maybe someone here can help me. I’ve been working on it for days and just can’t get any further.
My app has an AppHomeViewController.swift which contains all the code. I have 2 TableViews, one of which is filled correctly. The 2nd one shows the bars but the labels are not filled. Of course I have tried to go through the whole thing step by step to find the error. However, I cannot explain what is going wrong.
The outlets are set as well as the identifire and the classe.
Translated with DeepL.com (free version)
`class MailingsTableViewCell: UITableViewCell {
@IBOutlet weak var customerLabel: UILabel!
@IBOutlet weak var jobnumberLabel: UILabel!
@IBOutlet weak var productLabel: UILabel!
@IBOutlet weak var serviceLabel: UILabel!
func configure(with mailings: DataModelsContainer.MailingsData) {
print("Configuring cell with data: (mailings)")
guard let customerLabel = customerLabel else {
print("Error: customerLabel is nil")
return
}
customerLabel.text = mailings.customer
}
}`
I have the prints output to see if any data arrives at all.
Configuring cell with data: MailingsData(customer: "InterCash", jobnumber: "DE-HW-2104112", product: "Warenversand", service: "Economy") Error: customerLabel is nil
`// MARK: – TableView DataSource Sorter Shipments
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if tableView == self.tableView {
//rint("funktion tableView 1")
return dataModelsContainer?.shipmentData.count ?? 0
} else if tableView == mailingsTableView {
//print("funktion mailingsTableView 1")
return dataModelsContainer?.mailingsData.count ?? 0
}
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView == self.tableView {
let cell = tableView.dequeueReusableCell(withIdentifier: "ShipmentCell", for: indexPath) as! ShipmentTableViewCell
if let shipment = dataModelsContainer?.shipmentData[indexPath.row] {
cell.configure(with: shipment)
}
return cell
} else if tableView == mailingsTableView {
//let cell = mailingsTableView.dequeueReusableCell(withIdentifier: "MailingsCell", for: indexPath) as! MailingsTableViewCell
let cell = tableView.dequeueReusableCell(withIdentifier: "MailingCell", for: indexPath) as! MailingsTableViewCell
if let mailings = dataModelsContainer?.mailingsData[indexPath.row] {
cell.configure(with: mailings)
}
return cell
}
fatalError("Unknown table view")
}`
I’m really at my wit’s end.
Please excuse the stupid questions, but IOS development is something completely new to me and this is the first code I’ve written in IOS. It looks accordingly but it’s just for learning purposes.
Maybe one of you knows what the problem is or how I can work around it and force it to work.
Attached is a small screen and it is about the lower table. The one above works.
Many thanks in advance for your help
Sascha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.