jack
jack

Reputation: 622

What does "Value of type '(CGRect) -> CGRect' has no member 'height'" mean?

It seems the true cause of the error is I was trying to multiply a Double by a CGFloat. It took me a while to understand this through experimentation and I updated my code to use the equivalent of v3 below, but I still want to understand the error message.

class MyView: UIView {
  override public func layoutSubviews() {
    let value: Double = 0.0
    let v2 = value*self.frame.height // Error: Value of type '(CGRect) -> CGRect' has no member 'height'
    let v3 = CGFloat(value)*self.frame.height
  }
}

What is this error message trying to tell me?

Upvotes: 1

Views: 4315

Answers (1)

DonMag
DonMag

Reputation: 77486

self.frame.height is a CGFloat

You have declared value as a Double

This will work:

let v2 = value * Double(self.frame.height)

The error message should probably read:

Value of type '(CGRect) -> CGRect' has no member 'height' of type Double

Upvotes: 5

Related Questions