Bra*_*don 2 xcode objective-c nsstring cllocationmanager ios
我有两组地理坐标,我正在尝试计算它们之间的距离.我已经做了一些挖掘,但无法弄清楚如何做到这一点.我试图获得用户(userLatitude/userLongitude)和地点(placeLatitude/placeLongitude)之间的距离.我的坐标存储为NSStrings,如下所示.有谁知道如何做到这一点?谢谢你们!
NSString *userLatitude =[(PDCAppDelegate *)[UIApplication sharedApplication].delegate
getUserLatitude];
NSString *userLongitude =[(PDCAppDelegate *)[UIApplication sharedApplication].delegate
getUserLongitude];
NSString *placeLatitude = [element1 objectForKey:@"placeLatitude"];
NSString *placeLongitude = [element1 objectForKey:@"placeLongitude"];
Run Code Online (Sandbox Code Playgroud)
这可能对你有帮助.尝试从lat中创建CLLocation
CLLocation* Location1;
CLLocation* Location2;
CLLocationDistance distance = [Location1 distanceFromLocation:Location2];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3415 次 |
| 最近记录: |