Reputation: 39
I want to use the DeviceTableViewCell classics together with TDBadgedCell. How do we use the two clans together? For example, your cellBadgedCell class .I want to use badgeString with the cell class. It'il be the way I showed it in the code.
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cellBadgedCell = tableView.dequeueReusableCell(withIdentifier:"BadgedCell") as? TDBadgedCell;
if(cellBadgedCell == nil) {
cellBadgedCell = TDBadgedCell(style: .default, reuseIdentifier: "BadgedCell");
}
cellBadgedCell?.badgeString = demoItems[indexPath.row]["badge"]!
cellBadgedCell.badgeColor = .orange
let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! DeviceTableViewCell
return cell
}
The function I want should be like this:
cell?.badgeString = ıtems[indexPath.row]["badge"]!
cell.badgeColor = .orange
Upvotes: 0
Views: 80
Reputation: 378
may be you can define class DeviceTableViewCell: TDBadgedCell, and you can use badgeString and badgeColor
Upvotes: 2