diff --git a/Document/README/Usages.md b/Document/README/Usages.md
index 5d759ab..5b7d637 100644
--- a/Document/README/Usages.md
+++ b/Document/README/Usages.md
@@ -511,7 +511,9 @@ class Model: SmartDecodable {
Inheritance does not have a particularly good implementation in Codable, but SmartCodable provides a combination (@SmartFlat) that indirectly implements inheritance requirements.
-继承在Codable中没有特别好的实现方案, SmartCodable提供了组合方式(@SmartFlat)用来间接实现继承的需求。
+继承在Codable中没有特别好的实现方案, 这里提供两种方案:
+
+1. SmartCodable提供了组合方式(@SmartFlat)用来间接实现继承的需求。
```
let jsonString = """
@@ -539,7 +541,38 @@ struct SubModel: SmartCodable {
}
```
-
+2. 重写`init(from decoder: Decoder) ` 方法,接管解析。
+
+ ```
+ class BaseModel: SmartCodable {
+ var name: String = ""
+ var age: Int = 0
+
+ enum CodingKeys: CodingKey {
+ case name
+ case age
+ }
+ required init() { }
+ }
+
+ class SubModel: BaseModel {
+ var nickName: String = ""
+ enum CodingKeys: CodingKey {
+ case nickName
+ }
+ required init(from decoder: Decoder) throws {
+ try super.init(from: decoder)
+ let container = try decoder.container(keyedBy: CodingKeys.self)
+ self.nickName = try container.decode(String.self, forKey: .nickName)
+ }
+
+ required init() {
+ super.init()
+ }
+ }
+ ```
+
+
### Update Existing Model(更新现有模型)
diff --git a/Example/Podfile.lock b/Example/Podfile.lock
index fd4e633..d969bd5 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 (4.1.11-beta.3)
+ - SmartCodable (4.2.0)
- SnapKit (5.6.0)
DEPENDENCIES:
@@ -39,7 +39,7 @@ SPEC CHECKSUMS:
CleanJSON: 910a36465ce4829e264a902ccf6d1455fdd9f980
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
HandyJSON: 582477127ab3ab65bd2e471815f1a7b846856978
- SmartCodable: 5429462702dd8ac32fb664d98c367120cd331d37
+ SmartCodable: e1b30d724aa0c1c82964a8cef06709dc93154f4f
SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25
PODFILE CHECKSUM: 7f3af03f81934df0c035518074a7abbec8fa9d3f
diff --git a/Example/Pods/Local Podspecs/SmartCodable.podspec.json b/Example/Pods/Local Podspecs/SmartCodable.podspec.json
index 853fc4f..2f59c56 100644
--- a/Example/Pods/Local Podspecs/SmartCodable.podspec.json
+++ b/Example/Pods/Local Podspecs/SmartCodable.podspec.json
@@ -1,6 +1,6 @@
{
"name": "SmartCodable",
- "version": "4.1.11-beta.3",
+ "version": "4.2.0",
"summary": "数据解析库",
"homepage": "https://github.com/intsig171",
"license": {
@@ -12,7 +12,7 @@
},
"source": {
"git": "https://github.com/intsig171/SmartCodable.git",
- "tag": "4.1.11-beta.3"
+ "tag": "4.2.0"
},
"platforms": {
"ios": "11.0",
diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock
index fd4e633..d969bd5 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 (4.1.11-beta.3)
+ - SmartCodable (4.2.0)
- SnapKit (5.6.0)
DEPENDENCIES:
@@ -39,7 +39,7 @@ SPEC CHECKSUMS:
CleanJSON: 910a36465ce4829e264a902ccf6d1455fdd9f980
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
HandyJSON: 582477127ab3ab65bd2e471815f1a7b846856978
- SmartCodable: 5429462702dd8ac32fb664d98c367120cd331d37
+ SmartCodable: e1b30d724aa0c1c82964a8cef06709dc93154f4f
SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25
PODFILE CHECKSUM: 7f3af03f81934df0c035518074a7abbec8fa9d3f
diff --git a/Example/Pods/Target Support Files/SmartCodable/SmartCodable-Info.plist b/Example/Pods/Target Support Files/SmartCodable/SmartCodable-Info.plist
index cfd36e1..0ea6281 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
- 4.1.11
+ 4.2.0
CFBundleSignature
????
CFBundleVersion
diff --git a/SmartCodable.podspec b/SmartCodable.podspec
index f64733f..1a1492c 100644
--- a/SmartCodable.podspec
+++ b/SmartCodable.podspec
@@ -12,7 +12,7 @@
Pod::Spec.new do |s|
s.name = 'SmartCodable'
- s.version = '4.1.11-beta.4'
+ s.version = '4.2.0'
s.summary = '数据解析库'
s.homepage = 'https://github.com/intsig171'