Guest User

Untitled

a guest
Jan 23rd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  2. let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! TableViewCell
  3.  
  4. cell.title.text = "Some text"
  5. // config other data...
  6.  
  7. return cell
  8. }
  9.  
  10. protocol SomeCellProtocol {
  11. func setTitle(text: String)
  12. }
  13.  
  14. class SomeCell: UITableViewCell {
  15.  
  16. @IBOutlet weak var title: UILabel!
  17. }
  18.  
  19. extension SomeCell: SomeCellProtocol {
  20.  
  21. func setTitle(text: String) {
  22. title.text = text
  23. }
  24. }
  25.  
  26. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  27. let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! TableViewCell
  28.  
  29. cell.setTitle(text: "Some text")
  30. // config other data...
  31.  
  32. }
Add Comment
Please, Sign In to add comment