Skip to content
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 'Edge' and 'Double' #162

Open
ninjudd opened this issue Sep 16, 2015 · 3 comments

Comments

@ninjudd
Copy link

ninjudd commented Sep 16, 2015

I just updated to Swift 2.0, which required adding this to my Podfile for Cartography to compile:

pod 'Cartography', :git => 'https://github.com/robb/Cartography.git'

Now I am running into the following error:

Binary operator '+' cannot be applied to operands of type 'Edge' and 'Double'

Here is the relevant code:

constrain(intro, avatar) { intro, avatar in
    let introMargin = 30.0
    intro.left == intro.superview!.left + introMargin
    intro.right == intro.superview!.right - introMargin
    intro.top == avatar.bottom + 20.0
}

I can fix it by casting introMargin to CGFloat, but that will involve a lot of casting throughout my code. Is there a better solution?

Thanks!

@robb
Copy link
Owner

robb commented Sep 17, 2015

You could declare introMargin as CGFloat?

@ninjudd
Copy link
Author

ninjudd commented Sep 17, 2015

Yeah. Declaring it as a CGFloat solves the issue. That's what I meant actually :) Casting every use would be crazy.

I'm curious what caused this to change since it worked fine before. Is not working with Double a change in Cartography, or due to something in Swift 2.0?

@namanhams
Copy link

UIKit and CoreGraphics always use CGFloat for size/dimension, they never use Double. So i think we should use CGFloat here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants