Re: Convert CGFloat to NSNumber
Re: Convert CGFloat to NSNumber
- Subject: Re: Convert CGFloat to NSNumber
- From: Kyle Sluder <email@hidden>
- Date: Tue, 24 Feb 2015 11:02:22 -0600
On Tue, Feb 24, 2015, at 04:57 AM, Charles Jenkins wrote:
> 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 )
You need to create either a Double or Float from the CGFloat before you
can pass it to the NSNumber initializer:
1> let f: CGFloat = 2.0
f: CGFloat = 2
2> let p = NSNumber(double: Double(f))
p: NSNumber = Double(2)
--Kyle
_______________________________________________
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