https://stackoverflow.com/users/7496073/john-montgomery 의 코드를 이용하면 쉽다.

extension Dictionary {

    static func += (lhs: inout [Key:Value], rhs: [Key:Value]) {

        lhs.merge(rhs){$1}

    }

    static func + (lhs: [Key:Value], rhs: [Key:Value]) -> [Key:Value] {

        return lhs.merging(rhs){$1}

    }

}




 _ = json["data"]["summary"].arrayValue.map({

                    VD.s.vdTrendStat?.arrCgmCount += [$0["section"].stringValue : $0["count"].intValue]

                })




.

.

.

        GS.s.tp1?.labelUpperValue.text = String(describing: ((VD.s.vdTrendStat?.arrCgmCount.filter { $0.key == "high" })?.first?.value ?? 0))

'!A. Basics' 카테고리의 다른 글

iOS 디버깅 방법  (0) 2019.01.16
UISegmentedControl  (0) 2019.01.16
String, 소수점 두 자리 처리  (0) 2019.01.16
label 에서 ... 없애기  (2) 2019.01.15
한방에 알 수 있는 델리게이트 패턴  (0) 2019.01.15

+ Recent posts