Reputation: 1035
I'm populating a TableViewController given an array of NSManagedObjects of class "SampleClass". Although the number of objects in the fetched array returns correctly (i.e. if the table is to display 59 objects, 59 rows are created), the other parameters for the cell are "glitchy" to display.
For example, where there should be a title set by object.name, "null" until you click on the the cell, select another cell, and then come back to the initial cell.
I've tried `[tableview reloadData]' in the view will appear, and it still takes too long to load the data. Is there a better way to fill in the cell instead of:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
Class *classObject = [dataArray objectAtIndex:indexPath.row];
cell.textLabel.text = [classObject name].....
where dataArray points to the NSMutableFetchedArray from a coreData call
Note: the simulator misses filling more of the cells than the actual iPad. once another tab is selected however, all the cells display correctly when you return to the tab.`
Upvotes: 0
Views: 214
Reputation: 922
You may want to look into NSFetchedResultsController
It is a special class which is meant specifically for populating a table with results from a core data query.
In the past when using core data I have always used this class over other means.
Upvotes: 2