iOS/Swift
[Swift] Decodable로 들어오는 타입이 두 가지 일때
QuarterBaek
2019. 9. 3. 10:48
서버 리스폰스 값을 받던 도중
한가지 키값에 대해 경우에 따라 두가지 타입이 들어오는 것을 확인
가장 먼저 드는 생각은
서버 개발자에게....하하하하ㅏㅎ
말도 안되는 생각이란 걸 깨닫고
열심히 찾아봄
swift one key two type....
이딴 검색어를 써넣었음에도 불구하고
놀랍게도 아래와 같은 링크를 내려주시었다.
How do I handle decoding two possible types for one key in Swift?
I have a Codable struct that is used to decode incoming JSON. Unfortunately, sometimes one of its key's value is a string, and sometimes it is a float. I was able to cobble a couple of do/try/catch
stackoverflow.com
감사합니다.