-4

I use data.plist for populating UITableView. And I need to add cells with titles from String in the Dictionary and in the Array. How can i do it?

Root
--Array
-----Dictionary
-------**String**
-------Array2
-----Dictionary
-------**String**
-------Array2

I am using this code in viewDidLoad:

NSString *path = [[NSBundle mainBundle] pathForResource:@"Data"
                                                 ofType:@"plist"];

NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:path];
_mathArray = [dictionary objectForKey:@"Title"];

But it loads String, and String2

Root
--Array
-----Dictionary
-------String2
-------Array2
-----Dictionary
-------String2
-------Array2
-----**String**

enter image description here

4

1 回答 1

0

我假设您可以访问 plist 并存储在字典或数组中。所以我假设你已经有一个数组中的数据。

所以在 cellForRowAtIndexPath 中。你把字典拿出来做

NSDictionary* cellData = [plistArray objectAtIndex:indexPath.row];
[cell.textLabel setText:[cellData objectForKey:@"Title"]];

这会将单元格文本标签设置为 plist 数组中的标题。

于 2013-10-28T16:16:53.560 回答