gpt4 book ai didi

ios - 添加对象到 NSMutableArray

转载 作者:行者123 更新时间:2023-11-29 10:26:37 25 4
gpt4 key购买 nike

<分区>

我有一个方法可以为 map View 上的注释构建边界框。我正在尝试将当前用户的位置添加为注释,以确保它们包含在边界框中。

当我尝试将位置添加到 NSMutableArray 时,我收到一个错误,指出参数 CLLocationCoordinate2D 与 (id) 不兼容。当我将 currentLocation 设为指针(即 *currentLocation)时,我收到一个错误,指出它不兼容。

将此对象添加到 NSMutable 数组的正确方法是什么?有没有更好的方法来构建这个阵列?

- (void)zoomMapViewToFitAnnotations:(MKMapView *)mapView animated:(BOOL)animated
{
CLLocation *location = [self.locationManager location];
CLLocationCoordinate2D currentLocation = [location coordinate];

NSMutableArray *annotations = [[NSMutableArray alloc] initWithObjects:currentLocation, nil];
[annotations addObjectsFromArray:mapView.annotations];
...
}

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