gpt4 book ai didi

ios - UITableView 动态单元格内容

转载 作者:行者123 更新时间:2023-11-28 19:10:55 26 4
gpt4 key购买 nike

我用来创建一个 UITableView,其中的标签是使用 NSArray 创建的。按照教程 here .现在我正在尝试使用从我的服务器中提取的动态内容创建 UITableView。数据的提取与我指定的 JSON 配合得很好:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *responseString1 = [[NSString alloc] initWithData:responseData1 encoding:NSUTF8StringEncoding];

NSLog(@"%@",responseString1);

SBJsonParser *parser = [[SBJsonParser alloc] init];
id sample = [parser objectWithString:responseString1];

tempholder=[NSMutableArray arrayWithCapacity:[sample count]];

for (int i = 0; i < [sample count]; i++) {
[tempholder addObject:[[sample objectAtIndex:i]objectAtIndex:0]];
//NSLog(@"%@",[sample objectAtIndex:i]);
NSLog(@"%@",[tempholder objectAtIndex:i]);
}
}

那么我该如何替换

tableData = [NSArray arrayWithObjects:@"Item", @"Item",
@"Item", @"Item", @"Item", @"Item", @"Item",
@"Item", @"Item", nil];

这是我的

- (void)viewDidLoad

使用“tempholder”NSMutableArray

提前致谢...

最佳答案

将 tempHolder 数组设置为 tableData,然后在 connectionDidFinishLoading: 方法结束时重新加载 TableView 。

tableData = tempholder;
[self.tableView reloadData];

关于ios - UITableView 动态单元格内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15618843/

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