From 267bb2c2c94b8e453f455aa11fc8b012035ce2e8 Mon Sep 17 00:00:00 2001 From: Mccc Date: Sat, 11 May 2024 18:22:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B1=9E=E6=80=A7=E5=BF=BD?= =?UTF-8?q?=E7=95=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Example/Podfile.lock | 4 ++-- Example/Pods/Local Podspecs/SmartCodable.podspec.json | 4 ++-- Example/Pods/Manifest.lock | 4 ++-- .../SmartCodable/SmartCodable-Info.plist | 2 +- SmartCodable.podspec | 2 +- .../SmartJSONKeyedDecodingContainer+decode.swift | 7 ++++++- .../JSONDecoder/Decoder/InitialModelCache.swift | 10 ++++++++-- 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 24f16c0..165bead 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -8,7 +8,7 @@ PODS: - FBSnapshotTestCase/SwiftSupport (2.1.4): - FBSnapshotTestCase/Core - HandyJSON (5.0.0-beta.1) - - SmartCodable (3.4.0) + - SmartCodable (3.4.1) - SnapKit (5.6.0) - SQLiteRepairKit (1.3.0): - WCDBOptimizedSQLCipher (~> 1.3.0) @@ -49,7 +49,7 @@ SPEC CHECKSUMS: CleanJSON: 910a36465ce4829e264a902ccf6d1455fdd9f980 FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a HandyJSON: 582477127ab3ab65bd2e471815f1a7b846856978 - SmartCodable: 634142b85515a934e3c533f75444be33b8b74844 + SmartCodable: 9c9941a8303a8bedb16884a1c6efb27c91851126 SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25 SQLiteRepairKit: a66145aadae91886c800f75e16f5cc6476af1a93 WCDB.swift: 39e28fe29b5a3bf2927d9fb9218978f19bd49ff0 diff --git a/Example/Pods/Local Podspecs/SmartCodable.podspec.json b/Example/Pods/Local Podspecs/SmartCodable.podspec.json index e168abd..20a7f4a 100644 --- a/Example/Pods/Local Podspecs/SmartCodable.podspec.json +++ b/Example/Pods/Local Podspecs/SmartCodable.podspec.json @@ -1,6 +1,6 @@ { "name": "SmartCodable", - "version": "3.4.0", + "version": "3.4.1", "summary": "数据解析库", "homepage": "https://github.com/intsig171", "license": { @@ -12,7 +12,7 @@ }, "source": { "git": "https://github.com/intsig171/SmartCodable.git", - "tag": "3.4.0" + "tag": "3.4.1" }, "platforms": { "ios": "11.0", diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 24f16c0..165bead 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -8,7 +8,7 @@ PODS: - FBSnapshotTestCase/SwiftSupport (2.1.4): - FBSnapshotTestCase/Core - HandyJSON (5.0.0-beta.1) - - SmartCodable (3.4.0) + - SmartCodable (3.4.1) - SnapKit (5.6.0) - SQLiteRepairKit (1.3.0): - WCDBOptimizedSQLCipher (~> 1.3.0) @@ -49,7 +49,7 @@ SPEC CHECKSUMS: CleanJSON: 910a36465ce4829e264a902ccf6d1455fdd9f980 FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a HandyJSON: 582477127ab3ab65bd2e471815f1a7b846856978 - SmartCodable: 634142b85515a934e3c533f75444be33b8b74844 + SmartCodable: 9c9941a8303a8bedb16884a1c6efb27c91851126 SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25 SQLiteRepairKit: a66145aadae91886c800f75e16f5cc6476af1a93 WCDB.swift: 39e28fe29b5a3bf2927d9fb9218978f19bd49ff0 diff --git a/Example/Pods/Target Support Files/SmartCodable/SmartCodable-Info.plist b/Example/Pods/Target Support Files/SmartCodable/SmartCodable-Info.plist index 4e1b060..727eee8 100644 --- a/Example/Pods/Target Support Files/SmartCodable/SmartCodable-Info.plist +++ b/Example/Pods/Target Support Files/SmartCodable/SmartCodable-Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.4.0 + 3.4.1 CFBundleSignature ???? CFBundleVersion diff --git a/SmartCodable.podspec b/SmartCodable.podspec index ade563d..ccb2e96 100644 --- a/SmartCodable.podspec +++ b/SmartCodable.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.name = 'SmartCodable' - s.version = '3.4.0' + s.version = '3.4.1' s.summary = '数据解析库' s.homepage = 'https://github.com/intsig171' diff --git a/SmartCodable/Classes/JSONDecoder/Container/SmartJSONKeyedDecodingContainer+decode.swift b/SmartCodable/Classes/JSONDecoder/Container/SmartJSONKeyedDecodingContainer+decode.swift index c1439df..7789788 100644 --- a/SmartCodable/Classes/JSONDecoder/Container/SmartJSONKeyedDecodingContainer+decode.swift +++ b/SmartCodable/Classes/JSONDecoder/Container/SmartJSONKeyedDecodingContainer+decode.swift @@ -252,8 +252,13 @@ extension SmartJSONKeyedDecodingContainer { SmartLog.logDebug(error, className: className) } } + + // 如果被忽略了,就不要输出log了。 + let typeString = String(describing: T.self) + if !typeString.starts(with: "IgnoredKey<") { + logInfo() + } - logInfo() var decoded: T if let value = Patcher.convertToType(from: entry) { // 类型转换 diff --git a/SmartCodable/Classes/JSONDecoder/Decoder/InitialModelCache.swift b/SmartCodable/Classes/JSONDecoder/Decoder/InitialModelCache.swift index 9252064..0c11857 100644 --- a/SmartCodable/Classes/JSONDecoder/Decoder/InitialModelCache.swift +++ b/SmartCodable/Classes/JSONDecoder/Decoder/InitialModelCache.swift @@ -64,8 +64,12 @@ struct InitialModelCache { return caseValue.rawValue as? T } } else { // @propertyWrapper type, value logic - if let cacheValue = snapshots.last?.initialValues["_" + key.stringValue] as? IgnoredKey { - return cacheValue.wrappedValue + if let cacheValue1 = snapshots.last?.initialValues["_" + key.stringValue] { + if let value = cacheValue1 as? IgnoredKey { + return value.wrappedValue + } else if let value = cacheValue1 as? T { // 当key缺失的时候,会进入 + return value + } } } @@ -84,6 +88,8 @@ struct InitialModelCache { } return nil } + + }