Skip to content

Commit

Permalink
修复属性忽略的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
intsig171 committed May 11, 2024
1 parent f23f4ab commit 267bb2c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -49,7 +49,7 @@ SPEC CHECKSUMS:
CleanJSON: 910a36465ce4829e264a902ccf6d1455fdd9f980
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
HandyJSON: 582477127ab3ab65bd2e471815f1a7b846856978
SmartCodable: 634142b85515a934e3c533f75444be33b8b74844
SmartCodable: 9c9941a8303a8bedb16884a1c6efb27c91851126
SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25
SQLiteRepairKit: a66145aadae91886c800f75e16f5cc6476af1a93
WCDB.swift: 39e28fe29b5a3bf2927d9fb9218978f19bd49ff0
Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/SmartCodable.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SmartCodable.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>.convertToType(from: entry) { // 类型转换
Expand Down
10 changes: 8 additions & 2 deletions SmartCodable/Classes/JSONDecoder/Decoder/InitialModelCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
return cacheValue.wrappedValue
if let cacheValue1 = snapshots.last?.initialValues["_" + key.stringValue] {
if let value = cacheValue1 as? IgnoredKey<T> {
return value.wrappedValue
} else if let value = cacheValue1 as? T { // 当key缺失的时候,会进入
return value
}
}
}

Expand All @@ -84,6 +88,8 @@ struct InitialModelCache {
}
return nil
}


}


Expand Down

0 comments on commit 267bb2c

Please sign in to comment.