Convert CGFloat to NSNumber

2015-02-24 Thread Charles Jenkins
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

Re: Convert CGFloat to NSNumber

2015-02-24 Thread Roland King
On 24 Feb 2015, at 18:57, Charles Jenkins cejw...@gmail.com wrote: I’m surprised how painful it is to do trivial things in Swift. I’ve stopped being surprised at this. Between the anal type checking and the spew of optionals I spend all my time fiddling around trying to get a ‘?’ in the

Re: Convert CGFloat to NSNumber

2015-02-24 Thread Charles Jenkins
A structure?!? I did look it up in the documentation, and all I found was “the basic type for all floating-point values.” That the basis of all floating-point types could be a structure never occurred to me. Thanks! Swift is a language I want to like, but currently it makes the easy stuff hard

Re: Convert CGFloat to NSNumber

2015-02-24 Thread Roland King
On 25 Feb 2015, at 00:14, Charles Jenkins cejw...@gmail.com wrote: A structure?!? I did look it up in the documentation, and all I found was “the basic type for all floating-point values.” That the basis of all floating-point types could be a structure never occurred to me. Thanks!

Re: Convert CGFloat to NSNumber

2015-02-24 Thread Marco S Hyman
On Feb 24, 2015, at 10:16 AM, Quincey Morris quinceymor...@rivergatesoftware.com wrote: The following work, too (Xcode 6.1.1): let f1: NSNumber = font.pointSize let f2 = font.pointSize as NSNumber ... (Things may have changed in Swift 1.2, though.) Works fine in

Re: Convert CGFloat to NSNumber

2015-02-24 Thread Kyle Sluder
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

Re: Convert CGFloat to NSNumber

2015-02-24 Thread Quincey Morris
On Feb 24, 2015, at 08:14 , Charles Jenkins cejw...@gmail.com wrote: A structure?!? I did look it up in the documentation, and all I found was “the basic type for all floating-point values.” That the basis of all floating-point types could be a structure never occurred to me. That’s not