好吧,進入我的下一個困境。我做了大量的谷歌搜索,似乎有幾種方法可以解決這個問題,但似乎沒有一個適合我的表格視圖結構。我使用的Xcode 4.3.2 ARC和故事板。我有一個普通的視圖表視圖。我的表格由一系列城市及其部門組成(每行一個城市),當用戶選擇一個城市時,他們將被推送到關於該城市的詳細視圖。我想按字母順序整理我的表格,並帶有部分標題。任何建議,提示,教程鏈接,將不勝感激。表視圖組織成字母節
我有一個NSMutable陣列設置像這樣在我的表視圖的.m
NSMutableArray *dept;
- (void)viewDidLoad
{
[super viewDidLoad];
dept = [[NSMutableArray alloc] init];
City *thedept = [[City alloc] init];
[thedept setCityname:@"Albany"];
[thedept setPhone:@"5551237890"];
[dept addObject:thedept];
thedept = [[City alloc] init];
[thedept setCityname:@"Boston"];
[thedept setPhone:@"5556543435"];
[dept addObject:thedept];
thedept = [[City alloc] init];
[thedept setCityname:@"Springfield"];
[thedept setPhone:@"5553456323"];
[dept addObject:thedept];
thedept = [[City alloc] init];
[thedept setCityname:@"Tallahassee"];
[thedept setPhone:@"5552450988"];
[dept addObject:thedept];
thedept = [[City alloc] init];
[thedept setCityname:@"Vacouver"];
[thedept setPhone:@"5551312555"];
[dept addObject:thedept];
節頭可以只是字母表(A,B,C,d ...)的信。我想我需要通過他們的第一個字母預先整理我的城市,並且可能會根據字母命名該部分(如「sectionAcities」)。我給出的城市只有幾個,我總共有大約100個。
rishi,我看過那個教程謝謝。我知道的方法,我只是不知道如何實例化它與我的數組結構。我注意到TheElements示例使用了一個plist,這似乎讓我感到困惑。 – Chris