gpt4 book ai didi

iphone - CLLocation 生成奇怪的错误

转载 作者:行者123 更新时间:2023-12-03 21:21:44 25 4
gpt4 key购买 nike

我的 CLLocation 遇到问题。
我想知道两个坐标之间的距离,以便将其显示在 tableView 中位置标题旁边:

    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 框架与 MapKit 一起包含在内?

关于iphone - CLLocation 生成奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3966496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com