【发布时间】:2012-04-28 19:05:07
【问题描述】:
如何使用 insertRowsAtIndexPaths 将 getnewdata 的结果添加到我现有的 tableView 中?我找到了几个例子,但无法弄清楚。
- (void)getfirstdata {
[...] //get JSON data
self.data = jsonResult; //a dictionary inside of an array
[self.tableView reloadData];
}
- (void)getnewdata {
[...] //get new JSON data which has to be added to top of the table
self.data = jsonnewResult; //a dictionary inside of an array
[self.tableView reloadData];
}
(UITableViewCell *) tableView: (UITableView *) table_view cellForRowAtIndexPath: (NSIndexPath *) index_path
static NSString *CellIdentifier = @"Cell";
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
id celldata = [self.data objectAtIndex:[index_path row]];
cell.textLabel.text = [celldata valueForKeyPath:@"user.name"];
cell.detailTextLabel.text = [celldata objectForKey:@"text"];
return cell;
}
【问题讨论】:
-
您必须是 ruby 开发人员:-)。 Objective-c 约定是 camelCase。
标签: iphone arrays uitableview dictionary cell