Is a giant switch/case the right way to convert NSNumber to a generic type `T`?

as? and as! casting is restricted to bridgeable types only - it requires support partially from the compiler and partially from things that are available only to certain layers like the standard library or Foundation's overlay. I would suggest that the proper way above those layers is to use nullable initializers for conversion or nullable accessor methods/properties. Trying to shoehorn support for bridging out side of those types is a dark and torrid affair not recommended for the feint of heart or shipping apps ;)

1 Like