Files
Woka_Native_iOS/WOKA/Authentication/Model/IntrestTopicDM.swift

39 lines
1.0 KiB
Swift
Raw Normal View History

//
// IntrestTopicDM.swift
// WOKA
//
// Created by MacBook Pro on 07/05/24.
//
import Foundation
// MARK: - IntrestTopicDM
struct IntrestTopicDM: Codable {
let result: [Result]?
let totalRecords: Int?
enum CodingKeys: String, CodingKey {
case result
case totalRecords = "total_records"
}
// MARK: - Result
struct Result: Codable {
let id: Int?
let topicName: String?
var isSelected : Bool? = false
enum CodingKeys: String, CodingKey {
case id
case topicName = "topic_name"
case isSelected
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decodeIfPresent(Int.self, forKey: .id)
self.topicName = try container.decodeIfPresent(String.self, forKey: .topicName)
self.isSelected = (try? container.decodeIfPresent(Bool.self, forKey: .isSelected)) ?? false // Defaulting to false if nil
}
}
}