我有一个NSMutableArray *objectsArray;
包含字典,每个NSDictionary
有一个"Name"
字符串与对象名称值(没有意外)。 UITableView
已使用NSSortDescriptor
按名称升序排序。在NSMutableArray字典计数
现在我需要使用名字的第一个字母到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
所以,我需要知道如何返回段和正确的行数?
Ps。还有什么我必须做的,使其工作,如在细胞的创建过程cellForRowAtIndexPath
或通过objectsArray
通过segue
到DetailViewController
?
有关应用结构附加信息:
objectsArray是从plist中阵列字典。使用自定义原型单元填充表视图。 Xcode 4.2与故事板。 App for iPhone 5.1
您是否考虑实际编写一些软件来扫描您的阵列并提取信息? –
我没有考虑过任何东西。我是一般的编程新手,所以如果我找不到适合我的结构并且很容易理解的教程/示例代码,我不知道该怎么做。这就是我现在要求提供建议的原因。然后我会考虑答案。但我想这就是我需要做的事情,当我得到一些指导方针时,就像@mprivat让我以良好的答案开始。 – ingenspor
坦率地说,如果你是新手,你不应该用Objective-C编程 - 而应该从Java开始。从Objective-C开始,你会学到很多不良习惯,从不学习许多基础知识。世界可以再等上一个月或三个月,用于下一个伟大的病毒iPhone应用程序。 –