【发布时间】:2010-09-23 00:28:36
【问题描述】:
在将分段 plist 实现到 UITableView 中时,我陷入了困境。
我的 plist 设置如下。我有一个根数组,其中包含表示部分的字典。这些字典有一个单独的字符串“sectionname”,它指示节标题以及内部的字典数组来表示单元格(这样做的原因是允许对单元格进行计数并且仍然具有节标题)。
Root - Array
Item 0 - Dictionary
sectionname - string - A
RowsInSection - Array
Item 0 - Dictionary
name - string - Adam
Item 1 - Dictionary
name - string - Andrew
Item 1 - Dictionary
sectionname - string - B
RowsInSection - Array
Item 0 - Dictionary
name - string - Belle
Item 1 - Dictionary
name - string - Bob
Item 3 - Dictionary
[等等]。
现在,一切似乎都在工作,正确命名的标题在那里,正确的行数在它们的部分下。但是,这些行没有标签,对于我的生活,我无法弄清楚为什么。
我有一个 plist 的 NSMutableArray
libraryContent = [[NSMutableArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:libraryPlist ofType:@"plist"]];
section中的行数就是这样。
NSInteger count = [[[[doa libraryContent] objectAtIndex:section] valueForKeyPath:@"RowsInSection.@count"]intValue];
return count;
还有标题的标题。
return [[[doa libraryContent] objectAtIndex:section] objectForKey:@"sectionname"];
我尝试了以下方法无济于事。
cell.textLabel.text = [[[doa libraryContent] objectAtIndex:indexPath.row] valueForKey:@"name"];
我还在学习,这是从不同的地方拼凑起来的。 'doa' 方法链接到另一个声明了 'libraryContent' 的文件。
你们知道如何从 plist 中取出名字吗?或任何其他方法来做我想做的事?
【问题讨论】:
标签: iphone objective-c xcode uitableview