public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell2", for: indexPath) as! Cell2
var user: User
if shouldShowTheResult
{
user = self.filtered[indexPath.row]
}
else
{
user = MessageController.users[indexPath.row]
print(user.name)
}
cell.nameLabel.text = user.name <<-- Здесь возвращает nil
return cell
}
UILabel возвращает nil
Waver
#1
nubideus
#5
user не может быть null в этом случае.
func dequeueReusableCell(withIdentifier identifier: String) -> UITableViewCell?
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell2", for: indexPath) as! Cell2
почему так? сделать делать надо “as?”.