gpt4 book ai didi

iphone - Plist 到 UItableview

转载 作者:行者123 更新时间:2023-11-29 11:05:16 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Displaying Plist data into UItableview

我有一个带有字典和每个字典的字符串数的 plist。显示到下面的 url 中。这个项目列表在 plist 中。它给了我输出但是......没有正确显示......我认为问题位于 CellForRowatindexPath 中,如果 NSLOG valueArray 出现正确的输出

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

eneter image.

如何做到这一点?

我的代码:

- (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;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com