Bird
0
0

Which Swift protocol must a struct conform to for using a custom decoder configuration?

easy📝 Conceptual Q2 of 15
iOS Swift - Networking
Which Swift protocol must a struct conform to for using a custom decoder configuration?
AEncodable
BDecodable
CCodable
DObservableObject
Step-by-Step Solution
Solution:
  1. Step 1: Identify the protocol for decoding JSON

    The Decodable protocol allows a struct to be created from JSON data.
  2. Step 2: Differentiate from related protocols

    Encodable is for encoding, Codable combines both, but custom decoding specifically requires Decodable.
  3. Final Answer:

    Decodable -> Option B
  4. Quick Check:

    Custom decoder configuration requires Decodable [OK]
Quick Trick: Use Decodable to decode JSON into Swift structs [OK]
Common Mistakes:
  • Choosing Codable when only decoding is needed
  • Confusing with Encodable which is for encoding
  • Selecting unrelated protocols like ObservableObject

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes