0

所以我开发了一个独立的指南针应用程序(箭头旋转指向固定的纬度/经度点),它作为一个独立的项目完美地工作,但是当我将它合并到更广泛的项目中时,我遇到了一个问题。

最初我收到一个语义警告(不兼容的指针类型从'CLLoccation *__strong'分配给'CLLocationManager *'):

- (void)locationManager:(CLLocationManager *)manager 
didUpdateToLocation:(CLLocation *)newLocation 
       fromLocation:(CLLocation *)oldLocation {

if (newLocation.horizontalAccuracy >= 0) {

    self.recentLocation = newLocation; (WARNING HERE)

CLLocation *POI2location = [[CLLocation alloc]
                                initWithLatitude:kPOI2Latitude 
                                longitude:kPOI2Longitude];
    CLLocationDistance delta = [POI2location 

                                distanceFromLocation:newLocation];

此外,我收到一个致命错误(在“CLLocationManager”类型的对象上找不到属性“坐标”):

- (void)locationManager:(CLLocationManager *)manager
   didUpdateHeading:(CLHeading *)newHeading {

if (self.recentLocation != nil && newHeading.headingAccuracy >= 0) {
    CLLocation *POI2Location = [[CLLocation alloc]
                                initWithLatitude:kPOI2Latitude
                                longitude:kPOI2Longitude];

    double course = [self headingToLocation:POI2Location.coordinate
                                    current:recentLocation.coordinate]; (WARNING HERE)

出于某种原因,它现在不喜欢“recentLocation”,而之前它都工作得很好。有人可以向我指出我错过了什么。我敢肯定,对于比我更有经验的人来说,这是显而易见的。

提前谢谢了。

4

1 回答 1

0

今天早上又开始了,答案正盯着我看!

在 .h 文件中我会放

@property (strong, nonatomic) CLLocationManager *recentLocation;

当我应该放

@property (strong, nonatomic) CLLocation *recentLocation;
于 2012-06-22T09:25:13.680 回答