This is my first attempt at developing an iPhone, and I have UITableViewControllerone that will show the data returned from the web service.
In my AppDelegate, I have a timer set, which is called every few seconds and reloads the model. I keep the same link to the object and just update its contents, so I have the same object on any UITableViewControllerthat is currently displayed.
When the data is updated in AppDelegate, I call:
[[(UITableViewController *)[self.navigationController topViewController] tableView] reloadData];
The model is based on a collection of objects file. Each object filehas some properties and flags.
This works well if the current one UITableViewControlleris a simple single-partition table that maps each cell to a sequential index in an array files.
But I have one of UITableViewControllerwhich shows this information fileand, depending on the flag of the object file, will display 2 or 3 sections. I put this logic here:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if ([[_file status] intValue] & DOWNLOADING) {
kIndexTransferSpeed = 1;
kIndexSettings = 2;
return 3;
} else {
kIndexSettings = 1;
kIndexTransferSpeed = -1;
return 2;
}
}
So, on this controller, my -tableView:cellForRowAtIndexPath:is just a big statement ifthat will display a property from an object _file, depending on indexPath.
The problem with this approach is that when this table reloads on the device, I really see that it reloads. Section headings flash for a moment, and cells require a little attention. Specifically, if I scroll the table while it reloads.
- , - UITableViewController. ?
, " " , - tableView:cellForRowAtIndexPath:, AppDelegate [tableView reloadData]. " " , , , , .