How to cast from UInt16 to NSNumber
I have a UInt16 variable that I would like to pass to a legacy function that requires an NSNumber.
If I try:
var castAsNSNumber : NSNumber = myUInt16
I get a compiler error
'UInt16' is not convertible to 'NSNumber'
How can I recast this as an NSNumber?
- UnsafeMutablePointer<Void> to Concrete Object Type
- Swift: cannot convert value of type to @noescape while call indexOf, after filter using filter function
- Why does an NSInteger variable have to be cast to long when used as a format argument?
- Cast a Swift struct to UnsafeMutablePointer<Void>
- Core Data: Could not cast value of type 'MyType_MyType_2' to MyType
- Convert Int to String in Swift
Solutions Collect From Internet About “How to cast from UInt16 to NSNumber”
var castAsNSNumber = NSNumber(unsignedShort: myUInt16)
- iOS – automatically open app from background
- How to debug iOS apps in a jailbroken device with xcode 6.2
- Alternative strings for different targets of same App – use NSLocalizedString?
- Re-authenticating User Credentials Swift
- iPhone/iOS JSON parsing tutorial
- Why is self.view.subviews an empty array in viewDidLoad?
- How to hide status bar of a single view controller in iOS 9?
- iPhone iOS Amazon Scheme / URI Not Working Anymore amzn:// version 4.3.1 Deep Linking
- How to transition scenes in Swift
- PNG validation on iOS
- How do i replace spaces with +'s in Xcode
- Delete all my NSUserDefaults that start with a certain word
- How to create UIView ripple circle animation?
- Xcode IB: UIButton hidden but have still buttons space
- Manage Multiple UILocal Notification