Cartography
Cartography copied to clipboard
Binary operator '+' cannot be applied to operands of type 'Edge' and 'Double'
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!
You could declare introMargin
as CGFloat
?
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?
UIKit and CoreGraphics always use CGFloat for size/dimension, they never use Double. So i think we should use CGFloat here.