Missing return UITableViewCell
ch bin mir sicher, dass diese Frage schon einmal gestellt wurde, aber ich kann keine Antwort finden, die mein Problem mit verschachtelter if-else- und switch-case-Logik lös
Ich habe einUITableView
mit zwei Abschnitten hat jeder Abschnitt zwei benutzerdefinierte Zellen. Das ist es 4 Zellen. Aber egal was ich mache, ich bekomme "Fehlende Rückkehr in einer Funktion, von der erwartet wird, dass sie zurückkehrtUITableViewCell
"
Frag Wie kann ich dieses Setup so ändern, dass ich unten eine else-Anweisung erhalte, die der schnellen Logik entspricht?
Jede Hilfe wäre sehr dankbar
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if indexPath.section == 0{
switch (indexPath.row) {
case 0:
let cell0: SettingsCell! = tableView.dequeueReusableCellWithIdentifier("cell0", forIndexPath: indexPath) as! SettingsCell
cell0.backgroundColor = UIColor.redColor()
break
case 1:
let cell1: SettingsCell! = tableView.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath) as! SettingsCell
cell1.backgroundColor = UIColor.whiteColor()
break
default:
break
}
}
if indexPath.section == 1{
switch (indexPath.row) {
case 0:
let cell10: SettingsCell! = tableView.dequeueReusableCellWithIdentifier("cell10", forIndexPath: indexPath) as! SettingsCell
cell10.backgroundColor = UIColor.redColor()
break
case 1:
let cell11: SettingsCell! = tableView.dequeueReusableCellWithIdentifier("cell11", forIndexPath: indexPath) as! SettingsCell
cell11.backgroundColor = UIColor.whiteColor()
break
default:
break
}
}
}