没有 * 候选人产生预期的结果类型 FloatingPointRoundingRule

No * candidates produce the expected result type FloatingPointRoundingRule

在 Swift 3 中出现以下错误(在 Swift 2 中未发生):

No * candidates produce the expected result type FloatingPointRoundingRule

我不知道我需要做什么来修复它。

我正在尝试将纬度小数转换为 degrees/minutes/seconds

extension CLLocationDegrees {        
    mutating func toLatitudeSeconds() -> String {
        var seconds = Int(round(self * 3600)) //error here
        // etc ...
    }
}

舍入函数已更改为在实例上调用而不是全局函数。您基本上是在尝试执行 self.round(self*3600) 这不起作用,因为 round 函数不接受任何参数或类型为 FloatingPointRoundingRule 的参数。

你可能想要:

var seconds = Int((self*3600).rounded())