Plist 1.0.0

Plist 1.0.0

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布上次发布2017年3月
SwiftSwift版本3.0
SPM支持SPM

Benzi Ahamed维护。



Plist 1.0.0

  • Benzi Ahamed

Plist

一个简单的Swift库,用于处理plist文件和数据。受SwitfyJSON启发。

用法

import Plist

// initialize using an NSDictionary
// and retrieve keyed values

let info = Plist(dict)
let name = info["name"].string ?? ""
let age = info["age"].int ?? 0


// initialize using an NSArray
// and retrieve indexed values

let info = Plist(array)
let itemAtIndex0 = info[0].value

// load an applications info.plist data

let info = Plist(NSBundle.mainBundle().infoDictionary)
let identifier = info["CFBundleIndentifier"].string!

// utility initiaizer to load a plist file at specified path
let info = Plist(path: "path_to_plist_file")

// we support index chaining - you can get to a dictionary from an array via
// a dictionary and so on
// don't worry, the following will not fail with errors in case
// the index path is invalid
if let complicatedAccessOfSomeStringValueOfInterest = info["dictKey"][10]["anotherKey"].string {
  // do something
}
else {
  // data cannot be indexed
}

// you can also re-use parts of a plist data structure

let info = Plist(...)
let firstSection = info["Sections"][0]["SectionData"]
let sectionKey = firstSection["key"].string!
let sectionSecret = firstSection["secret"].int!

注意:要运行示例项目,请克隆仓库,然后首先在Example目录中运行pod install

要求

iOS 8+

安装

Plist可以通过CocoaPods获取。要安装它,只需将以下行添加到Podfile中:

pod "Plist"

手动安装

复制Plist.swift并将其放置在您选择的项目的适当位置,并将其包含在构建中。

作者

Benzi Ahamed,Twitter

许可证

Plist可在MIT许可证下获得。有关更多信息,请参阅LICENSE文件。

鼓励并欢迎贡献!