我是比较新的Objective-C和真的不很了解,所以我什么可能是一个非常业余的问题道歉。
我想从CLHeading和CLLocationDirection磁航向。 但是我得到的编译错误此行的代码:
locationLabel.text = [[[location course] magneticHeading] stringValue];
的错误是:
warning: invalid receiver type 'CLLocationDirection'
error: cannot convert to a pointer type
我真的不明白我在做什么错在这里。 请帮忙!
下面是使用指南针所需的步骤。
1)检查可用性:如果headingAvailable
外景经理的属性是YES,那么你可以使用指南针。
2)使用位置管理方法-(void) startUpdatingHeading
开始接收您正在搜索的信息
3)使用委托方法实际上检索该信息(不要忘记自己设置为代表)
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
希望这可以帮助。
magneticHeading是CLLocationDirection类型,这是简单地对基本数据类型的“双”一个typedef的。 在您的例子中,你正试图将消息发送到的东西是不是一个对象! 您应该简单地格式化,像这样的双:
locationLabel.text = [NSString stringWithFormat:@"Heading %.3f", [[location course] magneticHeading]];
你是如何分配和初始化location
? 确保location
被定义为(CLLocationDirection *)
而不仅仅是一个(CLLocationDirection)