xcode seems confused about the type of parameter required by a function

Xcode is indeed confused because you call an instance method on the class.

A solution is to make the function a class method.

And please name functions/methods with starting lowercase letter

static func degreesToRadians(degrees: Double) -> Double
{
    return degrees * .pi / 180.0
}

Another minor confusion is that the function is actually not related to the view controller with regards to contents.

For example you could create an extra struct for trigonometric functions

struct Trigonometry {
    static func degreesToRadians(degrees: Double) -> Double
    {
        return degrees * .pi / 180.0
    }
}

and call it

let voltageAngleRadians = Trigonometry.degreesToRadians(angleDeg)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top