-1

So I am just getting into the whole tableView thing but I came across a curious observations and have a question:

Why is it that overriding this function in my UITableViewController class

override func numberOfSections(in tableView: UITableView) -> Int

has a descriptive name but the number of rows in the section is determined this way

 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int

I find the former much more logical and wonder why it is not used consequently for other tableView parameters.

Why are different versions of the function tableView called for most tableView properties, instead of different functions with descriptive names?

I am sure there is a very good reason and would be thankful if someone wiser than me could shed some light on the issue.

Marmelador
  • 947
  • 7
  • 27
  • Look at this: http://stackoverflow.com/questions/26254875/why-do-all-methods-have-the-same-name-in-delegate – Sivajee Battina Apr 13 '17 at 05:10
  • check http://stackoverflow.com/questions/39172041/override-function and https://www.hackingwithswift.com/example-code/language/what-does-override-mean – ChintaN -Maddy- Ramani Apr 13 '17 at 05:11
  • But when compatibility with Objective-C is the reason, why is `numberOfSections` exempt from this? – Marmelador Apr 13 '17 at 05:28
  • Possible duplicate of [Why do all methods have the same name in delegate?](http://stackoverflow.com/questions/26254875/why-do-all-methods-have-the-same-name-in-delegate) – Stonz2 Apr 14 '17 at 18:00

1 Answers1

0

So to put it frankly: Compatibility with Objective-C seems to be the reason for this inconsistency.

Marmelador
  • 947
  • 7
  • 27