[swift-users] Foundation on Linux `CFBooleanGetTypeID`/`CFGetTypeID`

Jens Alfke jens at mooseyard.com
Tue May 24 15:18:18 CDT 2016


For completeness I should add that there are other cases where you need to know the exact type:

* When formatting a floating-point number, you should use 6 decimal places if it's a float, 16 if it's a double. (If you use all 15 for a float, you end up with results like “0.999999999999999” instead of “0.1”.)
* There’s an edge case in converting an NSNumber to an integer. Most of the time you can use longLongValue. But if the number is an unsigned 64-bit int (objcType == “Q”) you have to use unsignedLongLongValue, otherwise it may overflow and appear negative.

—Jens


More information about the swift-users mailing list