Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'

Question

How can I recast this as an NSNumber?

like image 796
PassKit Avatar asked Jun 10 '14 06:06

PassKit


1 Answers

var castAsNSNumber = NSNumber(unsignedShort: myUInt16)
like image 78
John Estropia Avatar answered Oct 06 '22 07:10

John Estropia