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 really what the quoted statement means.


On Feb 24, 2015, at 09:02 , Kyle Sluder <k...@ksluder.com> wrote:

> You need to create either a Double or Float from the CGFloat before you
> can pass it to the NSNumber initializer:

The following work, too (Xcode 6.1.1):

        let f1: NSNumber = font.pointSize
        let f2 = font.pointSize as NSNumber

What’s going on here, I think, is that NSNumber (in Obj-C) does not have an 
initializer that takes a CGFloat parameter, only initializers for float and 
double, but it never mattered (in Obj-C) because CGFloat was one of the other 
types. This carries over to Swift, except that there CGFloat is a distinct 
type, rather than being one or other of float or double.

AFAICT, the above forms work, not because there is an automatic conversion from 
CGFloat to double (let alone from CGFloat to NSNumber), but rather because 
CGFloat is FloatLiteralConvertible, and there are FloatLiteralConvertible 
variants of the ‘=‘ and ‘as’ operators.

(Things may have changed in Swift 1.2, though.)



_______________________________________________

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