서버 응답 json 제네릭 타입으로 디코딩 불가 이슈
Node 구조체의 멤버변수 Property의 타입이 제네릭이어서
Node struct 변경 전
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
struct Node { let id: String let icon: String? let cover: String? let title: String? let property: [Property<Any>] var rect: CGRect } //MARK: - 속성 model struct Property<T> { let name: String let type: PropertyType let value: T }
Node struct 변경 후
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
struct Node {
let id: String
let parrentId: String?
let icon: String?
let cover: String?
let title: String?
let property: [Property]
var rect: CGRect = .zero
mutating func setRect(rect: CGRect) {
self.rect = rect
}
}
//MARK: - 속성 model
struct Property {
let name: String
let type: PropertyType
let value: [ValueType]
}
struct ValueType {
let id: String
let name: String
let color: String
}
enum PropertyType {
case checkbox, // bool
email,
date,
formula,
multi_select, // array
number,
people,
phone_number,
relation, // array
rich_text,
select,
status,
title,
url
}
This post is licensed under CC BY 4.0 by the author.