I have an app that basically reads an xml file and displays the results in a UITableView. I am trying to group the list items by "country" (an attribute of the xml file elements) and display them in UITableView Sections.
Currently i read the xml file and store each Element as a custom object in an NSMutableArray. The array has the following structure:
Array: 0 => (title, description, date, country) 1 => (title, description, date, country) 2 => (title, description, date, country) 3 => (title, description, date, country)
I have tried creating another array of unique countries which has allowed me to create the section headers correctly but i am struggling to work out a way to display the correct items beneath each section header.
if(![countryArray containsObject:itemCountry]) //if country not already in array
{
[countryArray addObject:itemCountry]; //Add NSString of country name to array
}
Where itemCountry is the country attribute of each element as i loop through the xml file.
[countryArray count]; //gives me the amount of sections needed
So i guess my question is how do i work out how many rows need to go in each section? How do display the correct array items for each section?
Any help or pointers would be great