这是我的错误:
这是我在模块 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/