I'm parsing dictionaries returned by JSONSerialization.jsonObject. I would much prefer not to have to deal with NSNumber at all but JSONSerialization code returns booleans as a NSNumber
We use this in Alamofire, and it has been guarantee stable across platforms:
extension NSNumber {
fileprivate var isBool: Bool {
// Use Obj-C type encoding to check whether the underlying type is a `Bool`, as it's guaranteed as part of
// swift-corelibs-foundation, per [this discussion on the Swift forums](https://forums.swift.org/t/alamofire-on-linux-possible-but-not-release-ready/34553/22).
String(cString: objCType) == "c"
}
}