我有大约3000个词的定义,我正在加载到一个TableView中。现在,这只是一个排序的单词列表,没有添加它们。
我需要的部分添加到我的TableView数据(A,B,C ...),并似乎有几种方法可以做到这一点所以在我进入这个我要寻找一些确认或者如果我正在走错错误的兔子洞,那就更正了。
目前所述的TableView读取被存储为对象在每此代码一个NSMutableArray数据:
//AppDelegate.m
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
//...
NSMutableArray *wordArray = [[NSMutableArray alloc] init];
//Loop through result set from DB and populate objects
while([rs next]){
[wordArray addObject:[Word wordWith:[rs stringForColumn:@"word"]
Definition:[rs stringForColumn:@"definition"]
SectionIndex:[rs stringForColumn:@"sectionIndex"]]];
}
MainViewController *mainViewController =
[[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
mainViewController.listContent = wordArray;
//...
}
每个对象都有一个区段索引值([A-Z0-9]),所以我已经知道哪些部分每个单词进去,我知道这些部分需要什么,我可以轻松地为每个部分派生一个对象的数量。在填充NSMutableArray之前,所有单词都通过SQL进行了排序,以便处理完毕。
我可以用一个NSMutableArray创建多个部分,还是我需要做一些不同的事情?
感谢