AVISO: Cualquier pregunta que no cumpla ninguno de estos criterios podrá ser borrada sin previo aviso.

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's gravatar image

alvarogirona
206142123

editó 18 Sep '11, 13:09


  1. Asegurate de hacer retain al locations.
  2. Asegurate de hacer return cell; en el Datasource del UITableView
enlace permanente

respondido 18 Sep '11, 19:44

StaS's gravatar image

StaS
5.1k953

Tu respuesta:
Activar/desactivar vista previa

Sobre esta pregunta

Etiquetas de la pregunta:

×73
×45

Pregunta realizada el: 18 Sep '11, 12:51

Pregunta visitada: 897 veces

Última modificación: 18 Sep '11, 19:44

Seguir esta pregunta

Por Email:

Una vez que entres podrás suscribirte desde aquí para recibir actualizaciones

Por RSS:

Respuestas

Respuestas y Comentarios

Realizar Donación