Mi aplicación guarda la localización del usuario cada vez que este le da a un botón, para así tener un registro que después el usuario podrá consultar.
La aplicación guarda bien las localizaciones en un string y cuando hago un NSLog me salen listadas.
Pero cuando intento pasar el array de localizaciones a un TableView la aplicación peta.
Aquí esta el código:
- (void)viewDidLoad
{
[super viewDidLoad];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Locations" inManagedObjectContext:[CoreDataManager sharedInstance].managedObjectContext];
[fetchRequest setEntity:entity];
NSError *error;
locations = [[CoreDataManager sharedInstance].managedObjectContext executeFetchRequest:fetchRequest error:&error];
NSLog(@"%@ %@",[locations valueForKey:@"Longitude"], [locations valueForKey:@"Latitude"]);
// Do any additional setup after loading the view from its nib.
}
- (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];
}
// Configure the cell...
NSString *cellText = [[NSString alloc] initWithFormat:@"%@ %@",[[locations valueForKey:@"Latitude"]objectAtIndex:indexPath.row],[[locations valueForKey:@"Longitude"]objectAtIndex:indexPath.row]];
cell.textLabel.text = cellText;
}
¿De qué forma debo pasar los datos de CoreData al TableView?
Gracias
preguntado
18 Sep '11, 12:51
alvarogirona
206142123