【发布时间】:2010-09-30 16:05:54
【问题描述】:
我在使用 Sections 设置 cellForRowAtIndexPath 时遇到问题。如果我只显示所有“曲目”而不按“主题”分隔部分,那么它可以正常工作。
Track *aTrack = [appDelegate.tracks objectAtIndex:row];
cell.textLabel.text = aTrack.track_title;
我已经设置了我的 numberOfSectionsInTableView、numberOfRowsInSection、titleForHeaderInSection。这些都很好。但我真的不知道如何设置 cellForRowAtIndexPath。
在研究了更多之后,最好的方法似乎是使用 NSDictionary 来显示我的单元格...
NSDictionary *dictionary = [sectionTopicArray objectAtIndex:indexPath.section];
NSArray *array = [dictionary objectForKey:@"Tracks"];
NSString *cellValue = [array objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
有人可以给我一些关于如何制作一个可以保存我所有字典的 MutableArray(sectionTopicArray) 的指示吗?我可以在脑海中看到以下内容,但只是不知道如何用代码表达它。
sectionTopicArray
[0] Dictionary 1 with key Tracks
Track1
Track2
Track3
[1] Dictionary 2 with key Tracks
Track4
[2] Dictionary 3 with key Tracks
Track5
Track6
basically I'm thinking...
Section0 = Dictionary1 = Topic1
Section1 = Dictionary2 = Topic2
Section2 = Dictionary3 = Topic3
【问题讨论】:
-
轨道数据在哪里?它是在设备上的 SQLite DB 中,是驻留在内存中,还是根据需要从网上获取?
-
@John 解析了它的 XML。谢谢!
标签: iphone xcode uitableview nsxmlparser