tyczj tyczj - 2 months ago 11
iOS Question

No * candidates produce the expected result type FloatingPointRoundingRule

In swift 3 I am getting an error

No * candidates produce the expected result type FloatingPointRoundingRule
and I dont know what I need to do here to fix it.

I am trying to convert latitude decimal to degrees/minutes/seconds

extension CLLocationDegrees{

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


this was working in swift 2 so what is it asking for me to do here?

dan dan
Answer

The rounding functions were changed to be called on an instance rather than being global functions. You're basically trying to do self.round(self*3600) which doesn't work because the round function takes either no argument or an argument of type FloatingPointRoundingRule.

You probably want:

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