好吧,进入我的下一个困境。我做了大量的谷歌搜索,似乎有几种方法可以解决这个问题,但似乎没有一个适合我的表格视图结构。我使用的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