I have a value that is coming from the server, it's saving to NSString
variable (sometimes server return it as a string, sometimes as a boolean value).
Please assume that this part of the code could not be changed.
The problem came when I rewrote the Objc part to the swift 4
The code that I have in Objc:
[data.isActive boolValue]
In swift 4 it fails since there are no .boolValue
notation in String, you only could convert String to bool using Bool()
syntax. And since the value is not a real string, calling Bool()
would resolve in crashes because of CFBoolean unrecognized selector
since it was force wrapped from String.
Is there any way to overcome that without falling back for Objc code that would wrap those transformations?
Please check this test project on GitHub
It even fails on assigning those type of value to any swift object.