本文介绍了字符串到CLLocation纬度和经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个表示纬度和经度的字符串,如: - 56.6462520,我想分配给CLLocation对象以与我当前的位置进行比较。我尝试了以下代码,但我只得到错误:
I have two strings representing latitude and longitude like: "-56.6462520", and i want to assign then to a CLLocation object to compare to my current location.I tried the following code but i get errors only:
CLLocation * LocationAtual = [[CLLocation alloc]init];
LocationAtual.coordinate.latitude = @"-56.6462520";
LocationAtual.coordinate.longitude = @"-36.6462520";
然后将对象与我的实际位置纬度和经度进行比较。有什么建议?
and then compare the object with my actual location latitude and longitude. Any suggestions?
推荐答案
我认为你需要:
LocationAtual.coordinate.latitude = [@"-56.6462520" floatValue];
LocationAtual.coordinate.longitude = [@"-36.6462520" floatValue];
这篇关于字符串到CLLocation纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!