ios - GPS 坐标的完成 block

标签 ios swift core-location

由于我的应用程序使用户能够时不时地获取他们的位置,因此我确实可以使用在完成 block 中获取位置的功能。目前我已经使用设置了通知

NSNotificationCenter.defaultCenter().postNotificationName("functionToRun", object: nil) 

当用户请求位置时,我只需运行此函数

func getLocation() -> CLLocation {
    locationManager.requestLocation()
    return location
}

但是,这更新位置可能需要一段时间,并且只返回最新位置,我可以在完成 block 中实现此操作,以便获得实际位置吗?

最佳答案

CLLocationManager 并不完全以这种方式工作,但您可以轻松使用类似 CLLocationManager-blocks 的东西 cocoa pod 来获得此功能。只需通读文档即可确保其行为符合您的预期。

关于ios - GPS 坐标的完成 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39371109/

相关文章:

ios - 如何从 tableview 单元格中检索文本字段值

iOS Beacon 随时需要

swift - 枚举关联值的问题

iOS 9 延迟位置更新不起作用

ios - 当我在该地区时,CLRegionState 是未知的

Split View Controller 中的 iOS 静态页脚

ios - Swift:来自 XIB 文件的多个自定义 TableViewCells

iPhone 应用程序崩溃

ios - Swift:更新解析用户(PFUser)并在新注册后将图像保存到它

swift - 如何使用 RxSwift 和 Alamofire 进行分页?