Rightpoint / Anchorage

A collection of operators and utilities that simplify iOS layout code.
MIT License
632 stars 46 forks source link

Use of variables #24

Closed vandilsonlima closed 7 years ago

vandilsonlima commented 7 years ago

why can't I do this? let w = 100 view.widthAnchor == w Compile says

Binary operator '==' cannot be applied to operants of type NSLayoutDimension' and 'Int'

while this is possible view.widthAnchor == 100

ateliercw commented 7 years ago

@vandilsonlima the compiler is inferring that w is an int, to use a variable in a layout expression, the value needs to be a CGFloat

let w: CGFloat = 100
view.widthAnchor == w

Should compile

vandilsonlima commented 7 years ago

@ateliercw thanks for your help. I didn't notice that I should use a CGFloat instead of an Int.