Closed tsheaff closed 3 years ago
Swift.String
value is different to and non toll-free bridging NSString
instance.
If you really want to do it, explicit casting (like as NSString
in swift side) is unavoidable.
And unfortunately, NSString
is not compatible to AnyCodable
. See https://github.com/Flight-School/AnyCodable/issues/14#issuecomment-482815683.
I may be missing something fundamental here, but I'm having a difficult time making this library interoperate well with Objective C
Our API handler is in Swift but the object parser is in Objective C and difficult to refactor into Swift for now.
The API handler looks something like this:
Now in the objective-c object parser, we have something like this, where
data
is a single element from themyObjects
array from theMyObjectsResponse
above, being passed in from swift:This fails with the following exception:
In the debugger at the exception breakpoint:
How can I get
AnyCodable
to interoperate seamlessly with Objective C types and methods likeNSString
andisEqualToString:
?cc @mattt