我有一个NSMutableArray *objectsArray;
包含字典,每个字典NSDictionary
都有一个"Name"
以对象名称作为值的字符串(不足为奇)。UITableView
已按NSSortDescriptor
名称按升序排序。
现在我需要使用名称的第一个字母section
来访问 TableView ,但我找不到所需的代码:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
/*Return: How many letters from a-z are represented
as the first letter of the objects name?
I.e. If there is no object in the dictionary with name starting with letter B,
the number of sections are now 25 if all the other letters are included.*/
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//Return: How many objects are starting with each letter
所以我需要知道如何返回正确的部分和行数?
附言。我还需要做些什么才能使其正常工作,例如在单元格创建过程中cellForRowAtIndexPath
或在将 传递objectsArray
给segue
时DetailViewController
?
有关应用程序结构的其他信息:
objectsArray 来自带有字典的 plist 数组。使用自定义原型单元格填充表格视图。带有故事板的 Xcode 4.2。适用于 iPhone 5.1 的应用程序