Convert CGFloat to NSNumber
Convert CGFloat to NSNumber
- Subject: Convert CGFloat to NSNumber
- From: Charles Jenkins <email@hidden>
- Date: Tue, 24 Feb 2015 05:57:44 -0500
I’m surprised how painful it is to do trivial things in Swift. All I want to do is convert NSFont.pointSize to an NSNumber, but I can’t figure out any syntax the Swift compiler will accept.
My latest fruitless attempt has involved trying to simply cast the value into something for which NSNumber has a corresponding init():
let size:Float = font.pointSize as Float
let points = NSNumber( float: size )
Neither Float nor Double works. What the heck is a Swift CGFloat that seemingly makes it incompatible with everything else?
—
Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden