我有一個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應用程序。 –