About 1,910,000 results
Open links in new tab
  1. swift - When to use CodingKeys in Decodable - Stack Overflow

    Nov 2, 2021 · First of all there is a make-or-break rule for using CodingKeys: You can omit CodingKeys completely if the JSON – or whatever Codable conforming format – keys match …

  2. Swift Encodable, Decodable Vs Codable - Stack Overflow

    Mar 12, 2020 · Found in Apple doc, that Codable protocol is composed of Encodable and Decodable. Thus, Codable = Encodable & Decodable Now, let's say I implemented below …

  3. ios - How to directly convert a Dictionary to a Codable instance in ...

    Jul 1, 2021 · But it doesn't sound like you actually need any codable thing to be initializable from a Dictionary, just your model. In that case, rather than extend Decodable, just extend your model.

  4. swift - When to use decodable, Codable, and encodable to …

    Nov 14, 2021 · Codable means that the entity is both Encodable (ie can be encoded into data) and Decodable (can be decoded from data). When getting data from an API, you need …

  5. How do I make an enum Decodable in Swift? - Stack Overflow

    Jun 16, 2017 · How to make enums with associated types conform to Codable This answer is similar to @Howard Lovatt's but avoids creating a PostTypeCodableForm struct and instead …

  6. swift - Codable [String: Any] dictionary - Stack Overflow

    Think about what it means to conform to Codable. Conforming to Codable implies that your class can be converted to and from JSON. How do you convert a [String: Any] into a JSON format? …

  7. How do I use custom keys with Swift 4's Decodable protocol?

    Swift 4 introduced support for native JSON encoding and decoding via the Decodable protocol. How do I use custom keys for this? E.g., say I have a struct struct Address:Codable { var …

  8. ios - How to use Any in Codable Type - Stack Overflow

    Codable needs to know the type to cast to. Firstly I would try to address the issue of not knowing the type, see if you can fix that and make it simpler. Otherwise the only way I can think of …

  9. How can I use Swift’s Codable to encode into a dictionary?

    Jul 20, 2017 · 3 I definitely think that there's some value in just being able to use Codable to encode to/from dictionaries, without the intention of ever hitting JSON/Plists/whatever.

  10. codable - Creating custom CodingKey Object in Swift - Stack …

    Jun 5, 2019 · I'm trying to do something a little custom with my Codable objects. My JSON objects use several types of tokens, so I'd like to make them type safe. To do that, I've created the …