IOS Swift Tutorial 22 question

+1 i k · November 11, 2015
Hi, In this tableview code I do not understand the swift syntax:

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


I'm confused about the numberOfRowsInSection section: Int part. I thought that in Swift you have parameters as "name : type", but now we seem to have "two names : type" ? Is section a Int? But what does numberOfRowsInSection indicate here? The same question arises in the next function, this time with "cellForRowAtIndexPath indexpath : NSIndexPath"


Post a Reply


Oldest  Newest  Rating
0 Aju Antony · November 19, 2015

In Swift the parameters can me declared in two different ways "name: type" as you already know, and also "externalParameterName localParameterName: type".

The 'externalParameterName' is used when the function is called, and the 'localParameterName' is used as that variable name inside the current function.

for example,

func registerName (firstName firstEntry: String, lastName nextEntry: String) {
  firstEntry = //Do Something with firstEntry
  nextEntry = //Do Something with nextEntry


registerName(firstName: "Aju", lastName: "Antony")

and those functions are protocols for TableView Delegates. You can look into Protocols in Swift here,

Hope that clears it up for you :)

For more information on Functions in Swift, check here,

Happy Coding :D
  • 1

iOS Development / Swift


This forum is for questions, comments, and general discussion about iOS Development and Swift.

Bucky Roberts Administrator