我有一个基本上读取xml文件的应用程序,并在UITableView中显示结果.我试图按"country"(xml文件元素的属性)对列表项进行分组,并将它们显示在UITableView Sections中.
目前我读取了xml文件并将每个Element存储为NSMutableArray中的自定义对象.该数组具有以下结构:
数组:0 =>(标题,描述,日期,国家)1 =>(标题,描述,日期,国家)2 =>(标题,描述,日期,国家)3 =>(标题,描述,日期,国家)
我已经尝试创建另一个独特国家/地区阵列,这使我能够正确创建节标题,但我正在努力找到一种方法来显示每个节标题下面的正确项目.
if(![countryArray containsObject:itemCountry]) //if country not already in array
{
[countryArray addObject:itemCountry]; //Add NSString of country name to array
}
Run Code Online (Sandbox Code Playgroud)
其中itemCountry是每个元素的country属性,因为我循环遍历xml文件.
[countryArray count]; //gives me the amount of sections needed
Run Code Online (Sandbox Code Playgroud)
所以我想我的问题是我如何确定每个部分需要进行多少行?如何为每个部分显示正确的数组项?
任何帮助或指针都会很棒