Skip to content

Instantly share code, notes, and snippets.

@bhrott
Created March 31, 2017 16:36
Show Gist options
  • Save bhrott/4cdaa044e082b6a4c039e1c6f1c35dae to your computer and use it in GitHub Desktop.
Save bhrott/4cdaa044e082b6a4c039e1c6f1c35dae to your computer and use it in GitHub Desktop.
Swift :: Read PList
func read(name: String) -> [String: Any] {
if let fileUrl = Bundle.main.url(forResource: name, withExtension: "plist"),
let data = try? Data(contentsOf: fileUrl) {
if let result = try? PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [String: Any] {
return result!
}
}
return [:]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment