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.
Hope you understand what is mean by a section. I think row you already know. If you have any doubts post as a comment.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With