Rightpoint / Anchorage

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

Use of `BinaryFloatingPoint` types with custom operators. #58

Closed nickmshelley closed 6 years ago

nickmshelley commented 6 years ago

I feel like I'm probably just missing something stupid, but the following code demonstrates a problem I'm having:

let n: Double = 44
button.heightAnchor == 44 // works
button.heightAnchor == CGFloat(n) // works
button.heightAnchor == n // Failes with "Binary operator '==' cannot be applied to operands of type 'NSLayoutDimension' and 'Double'"

I feel like it should work without wrapping it because of this operator definition: https://github.com/Raizlabs/Anchorage/blob/master/Source/Anchorage.swift#L45.

Am I doing something wrong?

jvisenti commented 6 years ago

@nickmshelley Are you certain you're using the latest version of Anchorage (and also importing the module)? The snippet you provided compiles for me in Swift 4.0 / Xcode 9.2

nickmshelley commented 6 years ago

Iโ€™m on Xcode 9.3 (Swift 4.1). Maybe itโ€™s a new issue.

jvisenti commented 6 years ago

Ahh quite possibly. @ZevEisenberg did you address anything like this in #57 ?

ZevEisenberg commented 6 years ago

Yep, @nickmshelley's code compiles on my branch. We should get an update out!

ZevEisenberg commented 6 years ago

This should be fixed as of the newly-released 4.2.2. @nickmshelley please let us know if it's working for you now, and feel free to reopen or file a new issue if it's not.

nickmshelley commented 6 years ago

It works for us, thanks!

Funny story though... It turns out that we had copied the README line that pointed to 3.x, so we were using a year-old version. ๐Ÿ˜… When I saw @jvisenti's question I was away from my computer and just assumed we were on the latest since we very recently added the library to the project. Sorry if my bad assumption caused any unnecessary work.

As a side note, good call on updating the readme: https://github.com/Raizlabs/Anchorage/commit/f43a8ee8066c8a2dbe976d356ec2c13feba0e884#diff-04c6e90faac2675aa89e2176d2eec7d8 :)

jvisenti commented 6 years ago

@nickmshelley I noticed that Carthage documentation issue in the README by accident while we were releasing 4.2.2 ๐Ÿ˜… Glad it helped!