rockfordwei/perfect-ini
This project provides an encoder / decorder for [INI](https://en.wikipedia.org/wiki/INI_file) files.
Quick Start
This library provides a pair of INIEncoder and INIDecoder for INI files.
Encodable to INI
import PerfectINI
struct Person: Codable {
public var name = ""
public var age = 0
}
struct Place: Codable {
public var location = ""
public var history = 0
}
struct Configuration: Codable {
public var id = 0
public var tag = ""
public var person = Person()
public var place = Place()
}
let rocky = Person(name: "rocky", age: 21)
let hongkong = Place(location: "china", history: 1000)
let conf = Configuration(id: 101, tag: "my notes", person: rocky, place: hongkong)
let encoder = INIEncoder()
let data = try encoder.encode(conf)The outcome of encoder is a standard Swift Data object, and the content should be like this:
id = 101
tag = my notes
[person]
name = rocky
age = 21
[place]
history = 1000
location = chinaINI to Decodable
Assuming Configuration and data are ready:
let decoder = INIDecoder()
let config = try decoder.decode(Configuration.self, from: data)
// configuration loaded.Further Information
For more information on the Perfect project, please visit perfect.org.
Now WeChat Subscription is Available π¨π³
<p align=center><img src="https://raw.githubusercontent.com/PerfectExamples/Perfect-Cloudinary-ImageUploader-Demo/master/qr.png"></p>
Package Metadata
Repository: rockfordwei/perfect-ini
Default branch: master
README: README.md