Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the exact meaning of the indexPath.section?

From Apple's documentation about the method indexPathForRow, I am not clear on when and how to use indexPath.section and I am not clear on what exactly means a 'section'. I am new to iPhone development, can someone please help me explain 'section' a little?

From UIKit’s documentation:

row

An index number identifying a row in a UITableView object in a section identified by section.

section

An index number identifying a section in a UITableView object.

like image 907
trillions Avatar asked Oct 24 '11 19:10

trillions


2 Answers

enter image description here

Hope you understand what is mean by a section. I think row you already know. If you have any doubts post as a comment.

like image 156
Aravindhan Avatar answered Sep 30 '22 21:09

Aravindhan


You can have sections of rows. There always is at least one section for a table view. You can use numberOfSections method to change this. Similarly, tableView:numberOfRowsInSection: tells how many rows are in the given section. And finally tableView:cellForRowAtIndexPath: gives the cell given the row and section. For example, in the contacts application, each alphabet is a section. Its rows are all names starting with that letter. For example "S" will have "Samuel", "Sarah". Similarly, "A" will have "Ali", "Alex". I suggest you read this thoroughly.

like image 23
zakishaheen Avatar answered Sep 30 '22 20:09

zakishaheen