-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mccc
committed
Sep 3, 2024
1 parent
7c111c3
commit 4ab6cef
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Example/SmartCodable/平替HandyJSON/ReplaceHandyJSON_7ViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// ReplaceHandyJSON_7ViewController.swift | ||
// SmartCodable_Example | ||
// | ||
// Created by qixin on 2024/9/3. | ||
// Copyright © 2024 CocoaPods. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SmartCodable | ||
|
||
class ReplaceHandyJSON_7ViewController: BaseViewController { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
guard let data = readPlistData() else { return } | ||
|
||
if let model = Model.deserializePlist(from: data) { | ||
smartPrint(value: model) | ||
} | ||
|
||
} | ||
|
||
func readPlistData() -> Data? { | ||
// 获取plist文件的路径 | ||
if let path = Bundle.main.path(forResource: "SpecialData_data", ofType: "plist") { | ||
// 将plist文件的内容加载到Data对象中 | ||
if let data = FileManager.default.contents(atPath: path) { | ||
return data | ||
} else { | ||
print("无法读取plist文件内容") | ||
} | ||
} else { | ||
print("找不到plist文件") | ||
} | ||
return nil | ||
} | ||
|
||
struct Model: SmartCodable { | ||
var name: String? | ||
var age: Int? | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Example/SmartCodable/测试用例/解码/数据测试/SpecialData/SpecialData_data.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>age</key> | ||
<integer>20</integer> | ||
<key>name</key> | ||
<string>Mccc</string> | ||
</dict> | ||
</plist> |