New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binary operator '==' cannot be applied to operands of type 'Dimension' and 'Float' #140
Comments
So it seems to me (and I might be wrong! Please correct me) that you don’t have a type error for the first two statements, but your |
Yes exactly, sorry if it wasn't clear. It works if I just use numerical values. The only issue is that I can't drop the Constants.file, I the number isn't something I can hardcode. |
Are you saying that the values of the |
Yes, the values |
Alright — I’m largely ignorant of your codebase, but updating a |
I understand your concern, it's a bit counter-intuitive. It's dependent on the screen size; that's the only reason it's updated at run-time. With regards to your solution, wouldn't that still cause an issue since you're using a variable instead of a hardcoded number? |
Fair point. Upon further reflection, have you considered that maybe you might be approaching this problem incorrectly? Auto Layout encourages you to think in relative, constraint-based way, and updating button dimensions at runtime with absolute values goes against that philosophy — that shouldn’t be your job, it’s Auto Layout’s. A constants file make me think that you might be approaching this problem incorrectly. This apple documentation might prove useful — it explains the philosophy of Autolayout in a really good way. 👍 |
Thanks for your input (not sarcasm, I appreciate you taking the time to respond to me)! I will look into your suggestions. However, there are cases (outside of this) where I just need to set the height and width of something based off of dynamic values. If I don't solve this issue, I don't see how I could do that with cartography |
I understand that — but those dynamic values should be calculated by Auto Layout. And again! I don’t understand your codebase, nor the decisions you made. I am totally ignorant. It just seems the problem you’re describing is solved by Auto Layout far more directly. |
I can't reproduce this on my end, do you have more code that you can share? |
I want to create a button of a certain width and height:
However, I would also like to tie the numbers to variables rather than hard coded so I can change all button sizes at once. Ideally it would look like this
In a different file I have this structure
With this setup I receive the error For some reason I was under the impression that I attempted this with CGFloat and it failed before, however now when I force the Constants to use CGFloat instead of Float, it works perfectly. |
👍 |
I read in #36 and #56 that Cartography should be able to support floats, but I keep on receiving the error
Binary operator '==' cannot be applied to operands of type 'Dimension' and 'Float'
when I try this code:I have also tried it with CGFloat to no luck
The text was updated successfully, but these errors were encountered: