Iphone 将Plist数据显示到UItableview中
我有一个包含字典和每个字典的字符串数的plist。显示在下面的url中。plist中的项目列表以千为单位 我需要将这些plist数据显示到UItableview中 如何做到这一点 我的代码:Iphone 将Plist数据显示到UItableview中,iphone,ios,uitableview,plist,Iphone,Ios,Uitableview,Plist,我有一个包含字典和每个字典的字符串数的plist。显示在下面的url中。plist中的项目列表以千为单位 我需要将这些plist数据显示到UItableview中 如何做到这一点 我的代码: - (void)viewWillAppear:(BOOL)animated { // get paths from root direcory NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentD
- (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;
}
您已经用完了阵列的末尾
这可能是因为您已将每个部分的行数硬编码为5。除非每个部分中确实有5行,否则您应该在此处返回一个动态值。Ye谢谢…输出现在开始了…但形式不正确…请检查Rowatindexpath我如何知道您希望数据如何出来?好的…部分应显示@“通过”其中包含的行应显示所有字典值,包括passsearch plist问题..帮助可能重复的@NickBull该重复项已作为此重复项的重复项关闭。。。