2010-10-19 6 views
2

J'ai un problème avec un CLLocation.
Je voulais connaître la distance entre deux coordonnées pour le montrer à côté du titre de l'emplacement dans un tableView:CLLocation génère étrange Erreur

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; 
} 

// The first CLLocation based on the coordinates my MKMapView gives me. 
CLLocation *userLocation = [[CLLocation alloc] initWithLatitude:mapView.userLocation.coordinate.latitude longitude:mapView.userLocation.coordinate.longitude]; 

    // The second CLLocation based on the coordinates which are saved as a NSNumber in my own object 
CLLocation *locationForIndex = [[CLLocation alloc] initWithLatitude:[[[locations objectAtIndex:indexPath.row] latitude] doubleValue] longitude:[[[locations objectAtIndex:indexPath.row] longitude] doubleValue]]; 
CLLocationDistance distance = [userLocation distanceFromLocation:locationForIndex]; 

cell.textLabel.text = [[locations objectAtIndex:indexPath.row] title]; 
cell.detailTextLabel.text = [[NSString alloc] initWithString:[NSString stringWithFormat:@"%d", distance]]; 

return cell; 

Maintenant, l'erreur que je reçois est:

"_OBJC_CLASS_$_CLLocation", referenced from:

Est-ce que quelqu'un a une solution possible?

Merci!

Répondre

1

Avez-vous inclus le framework Core Location avec MapKit?

+0

Merci beaucoup! C'est la partie manquante !! –

+1

Ouais fait cela moi-même dans le passé. On pourrait penser que MapKit inclurait le Core Location mais pas ... –