Skip to content

Commit

Permalink
字典中包含Data的处理
Browse files Browse the repository at this point in the history
  • Loading branch information
Mccc committed Aug 28, 2024
1 parent 06a3c41 commit c3e4664
Show file tree
Hide file tree
Showing 134 changed files with 200 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// BaseCompatibilityViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/9/5.
// Created by Mccc on 2023/9/5.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion Example/SmartCodable/Base/BaseTwoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// BaseTwoViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/1/22.
// Created by Mccc on 2024/1/22.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion Example/SmartCodable/Base/Data+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Data+Extension.swift
// SmartCodable_Example
//
// Created by qixin on 2024/3/1.
// Created by Mccc on 2024/3/1.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// IntroduceViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/4/10.
// Created by Mccc on 2024/4/10.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Introduce_10ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/4/30.
// Created by Mccc on 2024/4/30.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Introduce_11ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/6/11.
// Created by Mccc on 2024/6/11.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Introduce_1ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/9/8.
// Created by Mccc on 2023/9/8.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Introduce_2ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/9/6.
// Created by Mccc on 2023/9/6.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Introduce_3ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/9/6.
// Created by Mccc on 2023/9/6.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Introduce_4ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/9/8.
// Created by Mccc on 2023/9/8.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Introduce_5ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/4/10.
// Created by Mccc on 2024/4/10.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Introduce_6ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/12/4.
// Created by Mccc on 2023/12/4.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Introduce_7ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/12/4.
// Created by Mccc on 2023/12/4.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Introduce_9ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/4/10.
// Created by Mccc on 2024/4/10.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// DecodingStrategyViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/3/26.
// Created by Mccc on 2024/3/26.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MixDecodingViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/3/28.
// Created by Mccc on 2024/3/28.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// DataDecodingStrategy.swift
// SmartCodable_Example
//
// Created by qixin on 2023/11/30.
// Created by Mccc on 2023/11/30.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// DateDecodingStrategy.swift
// SmartCodable_Example
//
// Created by qixin on 2023/11/30.
// Created by Mccc on 2023/11/30.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// NonConformingFloatDecodingStrategy.swift
// SmartCodable_Example
//
// Created by qixin on 2023/11/30.
// Created by Mccc on 2023/11/30.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// KeyDecodingStrategyViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/3/28.
// Created by Mccc on 2024/3/28.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CustomDecodingPathViewContriller.swift
// SmartCodable_Example
//
// Created by qixin on 2024/4/10.
// Created by Mccc on 2024/4/10.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CustomDecodingValueViewContriller.swift
// SmartCodable_Example
//
// Created by qixin on 2024/4/10.
// Created by Mccc on 2024/4/10.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// BeforeDecodingViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/3/28.
// Created by Mccc on 2024/3/28.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// FinishMappingViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/3/7.
// Created by Mccc on 2024/3/7.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// ConcurrenceLogViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/6/5.
// Created by Mccc on 2024/6/5.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// DecodingArrayLogViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/4/24.
// Created by Mccc on 2024/4/24.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CaseFiveViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/11/30.
// Created by Mccc on 2023/11/30.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CaseFourViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/11/22.
// Created by Mccc on 2023/11/22.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CaseOneViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/9/13.
// Created by Mccc on 2023/9/13.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// ComplexDataStructureDetailView.swift
// SmartCodable_Example
//
// Created by qixin on 2023/9/6.
// Created by Mccc on 2023/9/6.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// ComplexDataStructureDetailModel.swift
// SmartCodable_Example
//
// Created by qixin on 2023/9/6.
// Created by Mccc on 2023/9/6.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// File.swift
// SmartCodable_Example
//
// Created by qixin on 2023/9/6.
// Created by Mccc on 2023/9/6.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CaseThreeViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/11/22.
// Created by Mccc on 2023/11/22.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CaseTwoViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/10/27.
// Created by Mccc on 2023/10/27.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
49 changes: 29 additions & 20 deletions Example/SmartCodable/Test2ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test2ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/4/10.
// Created by Mccc on 2024/4/10.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand All @@ -15,29 +15,38 @@ class Test2ViewController: BaseViewController {
super.viewDidLoad()


let dict: [String: Any] = [
"error": "200",
"code": 400,
"data": [
"code": "abc",
"lyricType": "9999999",
"expriryTime": "NaN"
]

SmartConfig.debugMode = .none

guard let image = UIImage(named: "question") else { return }
let byte = UIImagePNGRepresentation(image)!


var dict111: [String: Any] = [
"id": "112312",
"name": "hello",
"byte": byte
]

// print(dict111)

guard let model = Model.deserialize(from: dict) else { return }
let model = DataModel11.deserialize(from: dict111)
print(model)
print(model?.thumbnail_picture)
}
}
struct DataModel11: SmartCodable {
/// 表id
var id: Int = -1
/// 名称
var name: String = ""
/// 缩略图流
var byte: Data? = nil

struct Model: SmartCodable {
var error: Int?
var code: Int?
var data: SubModel?
}

struct SubModel: SmartCodable {
var code: Int?
var lyricType: Int?
var expriryTime: Int?
var thumbnail_picture: UIImage? {
guard let byte = byte else {
return nil
}
return UIImage(data: byte)
}
}
2 changes: 1 addition & 1 deletion Example/SmartCodable/Test3ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test3ViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/4/18.
// Created by Mccc on 2024/4/18.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion Example/SmartCodable/TestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// TestViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2023/9/1.
// Created by Mccc on 2023/9/1.
// Copyright © 2023 CocoaPods. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// ReplaceHandyJSONViewController.swift
// SmartCodable_Example
//
// Created by qixin on 2024/3/26.
// Created by Mccc on 2024/3/26.
// Copyright © 2024 CocoaPods. All rights reserved.
//

Expand Down
Loading

0 comments on commit c3e4664

Please sign in to comment.