Codable & JSON Parsing
Codable protocol, JSONEncoder, JSONDecoder, custom keys, nested JSON, date strategies
1What is the Codable protocol in Swift?
What is the Codable protocol in Swift?
Відповідь
Codable is a typealias combining Encodable and Decodable. It enables serialization and deserialization of Swift structures to/from JSON or other formats. It's the standard mechanism for handling JSON in iOS without external frameworks.
2What is the difference between Encodable and Decodable?
What is the difference between Encodable and Decodable?
Відповідь
Encodable serializes a Swift instance into JSON data (object to JSON). Decodable performs the reverse operation, converting JSON into a Swift instance. These protocols are orthogonal: a struct can implement one, the other, or both as needed.
3What is the purpose of the CodingKeys enum during JSON decoding?
What is the purpose of the CodingKeys enum during JSON decoding?
Відповідь
CodingKeys maps Swift properties to actual JSON keys. It handles naming mismatches between Swift code (camelCase) and JSON (snake_case). Without CodingKeys, property names must exactly match JSON keys.
How to create a JSONDecoder instance to decode JSON?
What does JSONEncoder.encode() return after successful serialization?
+17 питань зі співбесід
Інші теми співбесід iOS
Swift Basics
Swift Language Essentials
UIKit Fundamentals
UIViewController Lifecycle
UserDefaults & Keychain
Application Lifecycle
Auto Layout & Constraints
UITableView & UICollectionView
SwiftUI Basics
SwiftUI State Management
SwiftUI Navigation
Networking & URLSession
Core Data
Protocol Oriented Programming
MVVM Architecture
Push Notifications
Unit Testing & XCTest
UI Testing
Xcode & Build System
Swift Package Manager
Memory Management & ARC
Combine Framework
Concurrency & async/await
iOS Design Patterns
Performance Optimization
Security & Encryption
SwiftUI Advanced
iOS Application Architecture
Опануй iOS для наступної співбесіди
Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.
Почни безкоштовно