SlideShare a Scribd company logo
Агрегация vs
Наследование
Как реализовать пагинацию
в вашем проекте?
Легко
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var currentPage = 1
var pageSize = 50
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == (currentPage * pageSize) - 1 {
currentPage += 1
tableView.reloadData()
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return pageSize * currentPage
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = String(indexPath.row)
return cell
}
}
Как добавить
пагинацию в другой
ViewController?
Легко
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var currentPage = 1
var pageSize = 50
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == (currentPage * pageSize) - 1 {
currentPage += 1
tableView.reloadData()
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return pageSize * currentPage
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = String(indexPath.row)
return cell
}
}
class AnotherViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var currentPage = 1
var pageSize = 50
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == (currentPage * pageSize) - 1 {
currentPage += 1
tableView.reloadData()
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return pageSize * currentPage
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "anotherCell", for: indexPath)
cell.textLabel?.text = "cell " + String(indexPath.row)
return cell
}
}
Хмм…
Мы получили
дублирование кода
Какие решения?
Легко
import UIKit
class PaginableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var currentPage = 1
var pageSize = 50
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == (currentPage * pageSize) - 1 {
currentPage += 1
tableView.reloadData()
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return pageSize * currentPage
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return cell(for: indexPath, in: tableView)
}
func cell(for indexPath: IndexPath, in tableView: UITableView) -> UITableViewCell {
fatalError("func must be overriden by subclass")
}
}
class ViewController: PaginableViewController {
override func cell(for indexPath: IndexPath, in tableView: UITableView) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = String(indexPath.row)
return cell
}
}
class AnotherViewController: PaginableViewController {
override func cell(for indexPath: IndexPath, in tableView: UITableView) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "anotherCell", for: indexPath)
cell.textLabel?.text = "cell " + String(indexPath.row)
return cell
}
}
Гений
OK. Теперь нам нужно
добавить refresh control
Легко
class ViewController: PaginableViewController {
@IBOutlet weak var tableView: UITableView!
var refreshControl: UIRefreshControl = {
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
refreshControl.tintColor = .red
return refreshControl
}()
override func viewDidLoad() {
super.viewDidLoad()
tableView.addSubview(refreshControl)
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
currentPage = 1
tableView.reloadData()
refreshControl.endRefreshing()
}
override func cell(for indexPath: IndexPath, in tableView: UITableView) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = String(indexPath.row)
return cell
}
}
Хмм…
Я должен создать
RefreshableViewController чтобы
иметь возможность
переиспользовать код
class RefreshableViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var refreshControl: UIRefreshControl = {
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
refreshControl.tintColor = .red
return refreshControl
}()
override func viewDidLoad() {
super.viewDidLoad()
tableView.addSubview(refreshControl)
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
loadFirstPage()
tableView.reloadData()
refreshControl.endRefreshing()
}
func loadFirstPage() {
fatalError("func should be overridden by subclass")
}
}
Давайте
унаследуем мой
ViewController от
RefreshableView
Controller
class ViewController: PaginableViewController
Агрегация
Виды отношений между
классами
• Ассоциация

• Агрегация

• Композиция

• Наследование
Асоциация
Означает, что два класса как-то связаны между собой, и мы пока не знаем точно, в чем эта связь
выражена и собираемся уточнить ее в будущем. Обычно это отношение используется на ранних
этапах дизайна, чтобы показать, что зависимость между классами существует, и двигаться
дальше.
Наследование
Более точным типом отношений является отношение открытого
наследования, которое говорит, что все, что справедливо для базового
класса справедливо и для его наследника.
Недостатки
наследования
• Далеко не все отношения между классами
определяются отношением «является»

• Наследование является самой сильной связью между
двумя классами, которую невозможно разорвать во
время исполнения (это отношение является
статическим и, в строготипизированных языках
определяется во время компиляции)
Композиция и агрегация
Оба они моделируют отношение «является частью» (HAS-A Relationship) и
обычно выражаются в том, что класс целого содержит поля (или свойства)
своих составных частей.
Разница между композицией и агрегацией
заключается в том, что в случае
композиции целое явно контролирует время
жизни своей составной части (часть не существует
без целого), а в случае агрегации целое хоть и
содержит свою составную часть, время их жизни
Композиция
class CustomService {
var object = CustomObject()
func doSomething() {
//Используем object
}
}
Агрегация
class CustomService {
weak var object: CustomObject?
init(object: CustomObject) {
self.object = object
}
func doSomething() {
//Используем object
}
}
Как это может быть
полезно в нашей
ситуации?
protocol RefreshableViewController: class {
var tableView: UITableView! { get }
func loadFirstPage()
}
class RefreshTableService {
weak var viewController: RefreshableViewController? {
didSet {
viewController?.tableView.addSubview(refreshControl)
}
}
lazy var refreshControl: UIRefreshControl = {
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
refreshControl.tintColor = .red
return refreshControl
}()
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
viewController?.loadFirstPage()
viewController?.tableView.reloadData()
refreshControl.endRefreshing()
}
}
class ViewController: PaginableViewController, RefreshableViewController {
@IBOutlet weak var tableView: UITableView!
var refreshTableService = RefreshTableService()
override func viewDidLoad() {
super.viewDidLoad()
refreshTableService.viewController = self
}
override func cell(for indexPath: IndexPath, in tableView: UITableView) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = String(indexPath.row)
return cell
}
func loadFirstPage() {
currentPage = 1
}
}

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Aggregation vs Inheritance

  • 4. class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { var currentPage = 1 var pageSize = 50 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if indexPath.row == (currentPage * pageSize) - 1 { currentPage += 1 tableView.reloadData() } } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return pageSize * currentPage } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.textLabel?.text = String(indexPath.row) return cell } }
  • 5. Как добавить пагинацию в другой ViewController?
  • 7. class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { var currentPage = 1 var pageSize = 50 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if indexPath.row == (currentPage * pageSize) - 1 { currentPage += 1 tableView.reloadData() } } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return pageSize * currentPage } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.textLabel?.text = String(indexPath.row) return cell } } class AnotherViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { var currentPage = 1 var pageSize = 50 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if indexPath.row == (currentPage * pageSize) - 1 { currentPage += 1 tableView.reloadData() } } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return pageSize * currentPage } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "anotherCell", for: indexPath) cell.textLabel?.text = "cell " + String(indexPath.row) return cell } }
  • 12. import UIKit class PaginableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { var currentPage = 1 var pageSize = 50 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if indexPath.row == (currentPage * pageSize) - 1 { currentPage += 1 tableView.reloadData() } } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return pageSize * currentPage } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { return cell(for: indexPath, in: tableView) } func cell(for indexPath: IndexPath, in tableView: UITableView) -> UITableViewCell { fatalError("func must be overriden by subclass") } } class ViewController: PaginableViewController { override func cell(for indexPath: IndexPath, in tableView: UITableView) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.textLabel?.text = String(indexPath.row) return cell } } class AnotherViewController: PaginableViewController { override func cell(for indexPath: IndexPath, in tableView: UITableView) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "anotherCell", for: indexPath) cell.textLabel?.text = "cell " + String(indexPath.row) return cell } }
  • 14. OK. Теперь нам нужно добавить refresh control
  • 16. class ViewController: PaginableViewController { @IBOutlet weak var tableView: UITableView! var refreshControl: UIRefreshControl = { let refreshControl = UIRefreshControl() refreshControl.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged) refreshControl.tintColor = .red return refreshControl }() override func viewDidLoad() { super.viewDidLoad() tableView.addSubview(refreshControl) } @objc func handleRefresh(_ refreshControl: UIRefreshControl) { currentPage = 1 tableView.reloadData() refreshControl.endRefreshing() } override func cell(for indexPath: IndexPath, in tableView: UITableView) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.textLabel?.text = String(indexPath.row) return cell } }
  • 18. Я должен создать RefreshableViewController чтобы иметь возможность переиспользовать код
  • 19.
  • 20. class RefreshableViewController: UIViewController { @IBOutlet weak var tableView: UITableView! var refreshControl: UIRefreshControl = { let refreshControl = UIRefreshControl() refreshControl.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged) refreshControl.tintColor = .red return refreshControl }() override func viewDidLoad() { super.viewDidLoad() tableView.addSubview(refreshControl) } @objc func handleRefresh(_ refreshControl: UIRefreshControl) { loadFirstPage() tableView.reloadData() refreshControl.endRefreshing() } func loadFirstPage() { fatalError("func should be overridden by subclass") } }
  • 23.
  • 24.
  • 25.
  • 27. Виды отношений между классами • Ассоциация • Агрегация • Композиция • Наследование
  • 28. Асоциация Означает, что два класса как-то связаны между собой, и мы пока не знаем точно, в чем эта связь выражена и собираемся уточнить ее в будущем. Обычно это отношение используется на ранних этапах дизайна, чтобы показать, что зависимость между классами существует, и двигаться дальше.
  • 29. Наследование Более точным типом отношений является отношение открытого наследования, которое говорит, что все, что справедливо для базового класса справедливо и для его наследника.
  • 30. Недостатки наследования • Далеко не все отношения между классами определяются отношением «является» • Наследование является самой сильной связью между двумя классами, которую невозможно разорвать во время исполнения (это отношение является статическим и, в строготипизированных языках определяется во время компиляции)
  • 31. Композиция и агрегация Оба они моделируют отношение «является частью» (HAS-A Relationship) и обычно выражаются в том, что класс целого содержит поля (или свойства) своих составных частей.
  • 32. Разница между композицией и агрегацией заключается в том, что в случае композиции целое явно контролирует время жизни своей составной части (часть не существует без целого), а в случае агрегации целое хоть и содержит свою составную часть, время их жизни
  • 33. Композиция class CustomService { var object = CustomObject() func doSomething() { //Используем object } }
  • 34. Агрегация class CustomService { weak var object: CustomObject? init(object: CustomObject) { self.object = object } func doSomething() { //Используем object } }
  • 35. Как это может быть полезно в нашей ситуации?
  • 36. protocol RefreshableViewController: class { var tableView: UITableView! { get } func loadFirstPage() } class RefreshTableService { weak var viewController: RefreshableViewController? { didSet { viewController?.tableView.addSubview(refreshControl) } } lazy var refreshControl: UIRefreshControl = { let refreshControl = UIRefreshControl() refreshControl.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged) refreshControl.tintColor = .red return refreshControl }() @objc func handleRefresh(_ refreshControl: UIRefreshControl) { viewController?.loadFirstPage() viewController?.tableView.reloadData() refreshControl.endRefreshing() } }
  • 37. class ViewController: PaginableViewController, RefreshableViewController { @IBOutlet weak var tableView: UITableView! var refreshTableService = RefreshTableService() override func viewDidLoad() { super.viewDidLoad() refreshTableService.viewController = self } override func cell(for indexPath: IndexPath, in tableView: UITableView) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.textLabel?.text = String(indexPath.row) return cell } func loadFirstPage() { currentPage = 1 } }