属性 在 CLLocationManager 类型的对象上找不到坐标
Property coordinate not found on object of type CLLocationManager
我正在构建一个跟踪用户位置、将他们的位置数据存储在数组中并在 MKOverlay 中绘制折线的小型应用程序。
我想我已经正确设置了所有内容,但我收到了上述错误:Property coordinate not found on object of type CLLocationManager
ViewController.h
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface ViewController : UIViewController <CLLocationManagerDelegate, MKMapViewDelegate, MKOverlay> {
CLLocationManager *locationManager;
NSMutableArray *trackingPointArray;
MKMapRect routeRect;
MKPolylineView *routeLineView;
MKPolyline *routeLine;
}
- (IBAction)startFollowing:(id)sender;
- (IBAction)stopFollowing:(id)sender;
@property (nonatomic, weak) IBOutlet MKMapView *mapView;
@end
问题代码
CLLocationDegrees Latitude = currentLocation.coordinate.latitude;
CLLocationDegrees Longitude = currentLocation.coordinate.longitude;
CLLocationCoordinate2D locationCoordinates = CLLocationCoordinate2DMake(Latitude, Longitude);
我想这可能是因为我没有在我的 .h 上声明对象,但是当我添加
@property (nonatomic, weak) CLLocation *coordinate;
我收到一个新错误:属性 类型 CLLocation
与继承自 MKOverlay
的类型 CLLocationCoordinate2D
不兼容
从我所看到的一切来看,这应该是可行的,但当然目前无法构建。将不胜感激朝着正确的方向前进。
答案就在眼前
再往上我有:
CLLocationManager *currentLocation = [locations lastObject];
错错错!!!
我应该有:
CLLocation *currentLocation = [locations lastObject];
我正在构建一个跟踪用户位置、将他们的位置数据存储在数组中并在 MKOverlay 中绘制折线的小型应用程序。
我想我已经正确设置了所有内容,但我收到了上述错误:Property coordinate not found on object of type CLLocationManager
ViewController.h
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface ViewController : UIViewController <CLLocationManagerDelegate, MKMapViewDelegate, MKOverlay> {
CLLocationManager *locationManager;
NSMutableArray *trackingPointArray;
MKMapRect routeRect;
MKPolylineView *routeLineView;
MKPolyline *routeLine;
}
- (IBAction)startFollowing:(id)sender;
- (IBAction)stopFollowing:(id)sender;
@property (nonatomic, weak) IBOutlet MKMapView *mapView;
@end
问题代码
CLLocationDegrees Latitude = currentLocation.coordinate.latitude;
CLLocationDegrees Longitude = currentLocation.coordinate.longitude;
CLLocationCoordinate2D locationCoordinates = CLLocationCoordinate2DMake(Latitude, Longitude);
我想这可能是因为我没有在我的 .h 上声明对象,但是当我添加
@property (nonatomic, weak) CLLocation *coordinate;
我收到一个新错误:属性 类型 CLLocation
与继承自 MKOverlay
CLLocationCoordinate2D
不兼容
从我所看到的一切来看,这应该是可行的,但当然目前无法构建。将不胜感激朝着正确的方向前进。
答案就在眼前
再往上我有:
CLLocationManager *currentLocation = [locations lastObject];
错错错!!!
我应该有:
CLLocation *currentLocation = [locations lastObject];