views:

23

answers:

1

I am creating an app that parses huge xml file and gets the data into table view. The user can enter text into search bar to search the table view.

Now, i want to make the table view into a sectioned one that is grouped alphbetically. Sine the table view is huge and the search functionality is included i want to know how to make the table view into sections... Any tutorials or source will be of great help...

+1  A: 

You must use a table view configured as an section index
See Table View Programming Guide for iOS

Populating an Indexed List

[...]An indexed list is a table view in the plain style that is specially configured through three UITableViewDataSource methods:

  • sectionIndexTitlesForTableView:
  • tableView:titleForHeaderInSection:
  • tableView:sectionForSectionIndexTitle:atIndex:

The first method returns an array of the strings to use as the index entries (in order), the second method maps these index strings to the titles of the table-view’s sections (they don’t have to be the same), and the third method returns the section index related to the entry the user tapped in the index.

The data that that you use to populate an indexed list should be organized to reflect this indexing model. Specifically, you need to build an array of arrays. Each inner array corresponds to a section in the table; section arrays are sorted (or collated) within the outer array according to the prevailing ordering scheme, which is often an alphabetical scheme (for example, A through Z). Additionally, the items in each section array are sorted. You could build and sort this array of arrays yourself, but fortunately the UILocalizedIndexedCollation class makes the tasks of building and sorting these data structures and providing data to the table view much easier. The class also collates items in the arrays according to the current localization.

Benoît
Thanks for the detailed explaination. Can u plz provide any tutorial or source code so that i can understand it better...!!!
Rahul Varma
Have you try the 3 related sample code of the guide ?
Benoît
TheElements sample code give an example http://developer.apple.com/library/ios/#samplecode/TheElements
Benoît