• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Convert CGFloat to NSNumber
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Convert CGFloat to NSNumber
      • From: Kyle Sluder <email@hidden>
    • Re: Convert CGFloat to NSNumber
      • From: Roland King <email@hidden>
  • Prev by Date: Re: Latest Documentation for adding Applescript Support to an Objective-C Project
  • Next by Date: [RESOLVED] Re: What's wrong with this code, why is the label invisible?
  • Previous by thread: Re: Displaying multiple errors in NSOpenPanel beginSheetModalForWindow:completionHandler:
  • Next by thread: Re: Convert CGFloat to NSNumber
  • Index(es):
    • Date
    • Thread