嗨我有一个plist文件,我从它的hiarchy读取就像这样:
Root - 词典 Date1数组(用字典填充) Date2数组(用字典填充) 等
如何使用数组标题填充我的UITableView?
答案 0 :(得分:0)
您可以使用NSDictionary
方法访问根allKeys
的密钥:
NSString *path = [[NSBundle mainBundle] pathForResource:@"MyData" ofType:@"plist"];
NSDictionary *rootDict = [[[NSDictionary alloc] initWithContentsOfFile:path] autorelease];
NSLog(@"%@", [[rootDict allKeys] objectAtIndex:0]); // Should return Date1Array
因此,在您的UITableViewDataSource方法中,您可以访问正确的密钥:
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Assumes the plist's root dictionary has been retained using a property:
NSString *arrayName = [[self.rootDict allKeys] objectAtIndex:indexPath.row];
//... configure cell
}