Objective-C is very typeinsensitive, from the BOOL perspective 0, "0", "NO", ``false, "false" and even nil is false, everything else is treated as true. That’s why NSString has a boolValue property. It just returns value != 0.
Swift is a strong typed language. You have to check the type:
let value : StringOrBool
let result : Bool
switch value {
case let boolValue as Bool: result = boolValue
case let stringValue as String: result = stringValue == "1" || stringValue == "true"
default: result = false
}
17
solved Access CFBoolean that is wrapped inside NSString in Swift 4