views:

20

answers:

0

Hello guys, I have a CoreData based iPhone application, which is shipped with some basic data which are updated from the Internet. My problem is that the changes I make in the values of the Entity are not populated in the table view.

This is my updating procedure:

NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Team" 
            inManagedObjectContext:managedObjectContext];
NSError *error;
NSMutableArray *mutableFetchResults;
NSPredicate *predicate;

Team *team;
//disable faulting
[request setReturnsObjectsAsFaults:NO];

[request setFetchLimit:1];

predicate = [NSPredicate predicateWithFormat:@"(name like[cd] %@)", [dict objectForKey:@"name"]];

[request setPredicate:predicate];
[request setEntity:entity];

mutableFetchResults = [[managedObjectContext executeFetchRequest:request
                 error:&error] mutableCopy];

if (mutableFetchResults == nil)
{
 DebugLog(@"Cannot find team: %@",[dict objectForKey:@"name"]);
} else {

 team = [mutableFetchResults objectAtIndex:0];

 team.points = [dict objectForKey:@"points"];

 DebugLog (@"%@ - %d", team.name, [team.points intValue]);
}

[request release];

Basically, I'm creating a predicate to find the right entity to update a change the value. I know from the DebugLog that the team entity got the right value. However, in time of displaying the values in the tableview, I get previous data:

-(UITableViewCell *)tableView:(UITableView *)tView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"StandingsTableViewCell";

StandingsTableViewCell *cell = (StandingsTableViewCell*)[tView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
 [[NSBundle mainBundle] loadNibNamed:@"StandingsTableViewCell" 
          owner:self
        options:nil];
 cell = tableCell;

}

Team *team = (Team*)[teamsArray objectAtIndex:indexPath.row];

cell.teamName.text = team.name;
cell.teamPoints.text = [team.points stringValue];

DebugLog(@"Name: %@: %d", team.name, [team.points intValue]);
return cell;

}

Does anyone have an idea what'd going on there?

Thanks Robert