CLLocation distanceFromLocation(在Swift中?) [英] CLLocation distanceFromLocation (in Swift?)

查看:114
本文介绍了CLLocation distanceFromLocation(在Swift中?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我将下面的Objective-C语句转换为Swift吗?

Can somebody please help me convert the following Objective-C statement to Swift?

CLLocationDistance distance = [fromLocation distanceFromLocation:toLocation];

我知道做到这一点必须很简单.我是iOS编程的新手,将不胜感激.

I know that it must be simple to do that. I am brand new to iOS programming and any help will be greatly appreciated.

谢谢! :-)

推荐答案

let distance = fromLocation.distanceFromLocation(toLocation)

新语法:

let distance = aLocation.distance(from: anotherLocation)

这篇关于CLLocation distanceFromLocation(在Swift中?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆