swift - 命名元组 - Swift - 如何使用

标签 swift tuples

这是我的错误: My Error 这是我在模块 A 中的函数:

func current_street(){
   var l = theCoreLocationController?.ltuple //lat,long
   let g = GeocodeObject(lat: l.lat, long: l.long, userstate: USER_STATE)
}

这是模块 B 中的 CoreLocationController 类:

public class CoreLocationController : NSObject, CLLocationManagerDelegate {
    public var ltuple: (lat:Double, long:Double)?;
    ...

这是模块 C 中 theCoreLocationController 的声明:

var theCoreLocationController: CoreLocationController?

最佳答案

您的ltuple是可选的。为了实现你想要的,你应该打开它。例如

func current_street(){
   if let l = theCoreLocationController?.ltuple //lat,long {
     let g = GeocodeObject(lat: l.lat, long: l.long, userstate: USER_STATE)
     // ...
   }
}

关于swift - 命名元组 - Swift - 如何使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28659126/

相关文章:

swift - 如何复制具有物理属性的 Sprite 然后将其添加到场景中?

Hadoop Pig 一行包含多条记录

arrays - 如何在 Swift 中对元组数组中的相似元组进行平均

ios - 如何更改 UIToolbar 高度?

ios - SwiftUI 如何实现暗模式切换并刷新所有 View

ios - 尽管 UIAlertController 在 View 层次结构中,但呈现一个 ViewController

ios - 继续引用

c++ - 如何从 C++ 元组中获取 Args...

python - 如何以pythonic方式将元组一分为二

arrays - 按行和按列对元组进行排序