iOS Enhance a Weather App with Table Views Next Week’s Weather Displaying Information in the Table View

Mathis Claßen
Mathis Claßen
4,892 Points

Data Source protocol

I used these functions before without caring to much how they work.

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {}

"numberOfRowsInSection" and "cellForRowAtIndexPath" are functions of UITableView, they are closures of some sort. After a lot of brainbending I finally understood how completion handlers work, since closures are some kind of "lovecraftian" concept for me [its powerful and huge but trying to understand it makes you insane].

In both functions I do nothing with the provided parameters and only return an Int or an UITableViewCell. I understand that the Class holding these functions is a delegate of UITableView and UITableView calls this functions when needed, populating them with those parameters. Maybe I do not need to know, but how does that all work together.