質問

私は凝集に問題があります。
2つの座標間の距離を知り、テーブルビューの場所のタイトルの隣に表示したかった:

    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;

これで私が得るエラーは次のとおりです。

"_OBJC_CLASS_$_CLLocation", referenced from:

誰かが可能な解決策を持っていますか?

ありがとう!!

役に立ちましたか?

解決

Core Location FrameworkとMapKitを含めましたか?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top