【发布时间】:2012-10-02 11:02:23
【问题描述】:
我正在制作一个应用程序来使用 CLLocation 管理器获取 GPS 位置。由于我正在使用 ios 6 更改:
-(void)locationManager *) didUpdateLocations:(NSArray *)locations
然后我声明了一个委托,这样我就可以在我的视图控制器中接收位置更新,然后将它们传递给我的显示标签,我在 didUpdateLocations 中使用了这个命令:
[self.delegate locationsUpdate:[locations lastObject];
考虑到位置最后一个对象 == 我曾经在
中使用的新位置-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation*)newLocation
fromLocation:(CLLocation *)oldLocation
但是当我像这样在我的视图控制器中调用我的更新位置时:
-(void)locationUpdate:(CLLocation *)location
{
locationLabel.text = [locations lastobject];
}
我得到一个错误。在以前的版本中,locationUpdate 中的命令应该是:
locationLabel.text = [location description];
有人知道如何声明命令以获取数组的最后一个对象并显示它吗?
提前致谢
【问题讨论】:
-
错误是什么?
locationLabel.text = [location description];不工作? -
我使用的是 locationLabel.text = [locations lastobject];不知道我为什么这样做:P 感谢您指出使用描述。由于 ios 6 的功能更改,我在课堂上使用了不同的声明,认为它不起作用。无论如何,谢谢:p
标签: objective-c ios cllocationmanager