> On Jul 26, 2015, at 16:07 , Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> On Jul 26, 2015, at 15:57 , Rick Mann <rm...@latencyzero.com> wrote:
>> 
>> I'm finding it a bit cumbersome to use CGFloat in graphics code in Swift, 
>> because the compiler won't let me pass a floating-point literal to a 
>> parameter that takes a CGFloat. I have to wrap them all in CGFloat(<val>).
> 
> I’m not seeing this. Do you have an example that produces an error in a 
> playground?

Well, I'm trying, but Xcode crashes evaluating it. Here's the (iOS) playground:

        http://pastebin.com/UM8NWS34

import CoreGraphics
import UIKit

let ctx = UIGraphicsGetCurrentContext()

func
addArc(inCenter : CGPoint, _ inRadius : CGFloat, _ inStartAngle : CGFloat, _ 
inEndAngle : CGFloat, _ inClockwise : Bool = false)
{
    CGContextAddArc(ctx, inCenter.x, inCenter.y, inRadius, inStartAngle, 
inEndAngle, inClockwise ? 1 : 0)
}


addArc(CGPoint(x: 0, y: 0), 50.0, 0.0, M_PI)


I thought maybe the problem is that I'm not naming arguments in my CG wrapper 
function, and Swift isn't matching it because of the types? Weird, 'cause 
there's just the one function (it's actually a member in a class).

But no, that doesn't seem to be it. I added names, and it still doesn't like 
it. The error I get in both cases is "cannot invoke 'addArc' with an argument 
list of type '(CGPoint, CGFloat, Double, Double)'"



-- 
Rick Mann
rm...@latencyzero.com



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to