显示Plist数据到UItableview

我有一个plist字典和每个字典的string数量。显示在下面的URL。这个项目列表是plist中的成千上万。

我需要将这些plist数据显示在UItableview中

进取者形象

这个怎么做?

我的代码:

- (void)viewWillAppear:(BOOL)animated { // get paths from root direcory NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [documentPaths objectAtIndex:0]; NSString *documentPlistPath = [documentsDirectory stringByAppendingPathComponent:@"p.plist"]; NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:documentPlistPath]; valueArray = [dict objectForKey:@"title"]; self.mySections=[valueArray copy]; NSLog(@"value array %@",self.mySections); } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [self.mySections count]; } -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { NSString *key = [[self.mySections objectAtIndex:section]objectForKey:@"pass"]; return [NSString stringWithFormat:@"%@", key]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.mySections count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; } // Configure the cell... NSUInteger section = [indexPath section]; NSUInteger row = [indexPath row]; cell.textLabel.text = [[self.mySections objectAtIndex:row] objectForKey:@"title"]; cell.detailTextLabel.text=[[self.mySections objectAtIndex:section] objectForKey:[allKeys objectAtIndex:1]]; return cell; } 

你跑了arrays的末尾。

这可能是因为你已经硬编码每个部分的行数为5.除非每个部分中真的有5行,否则应该在这里返回一个dynamic值。