Created
August 7, 2018 14:24
-
-
Save ramiresnas/ddc56e480c8b03291aec07ca2174b462 to your computer and use it in GitHub Desktop.
create a property list
This file contains hidden or 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
| //MARK: PList | |
| func createPList() { | |
| let fm = FileManager.default | |
| let docDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first | |
| guard let dir = docDirectory else {return} | |
| let path = dir.appending("/example.plist") | |
| if !fm.fileExists(atPath: path) { | |
| let dict = [["name":"Ramires","age":24,"salary":798.89],["name":"Bia","age":18,"salary":798.89]] as NSArray | |
| if dict.write(toFile: path, atomically: true) { | |
| print("created on \(path)") | |
| } else { | |
| print("error to create \(docDirectory ?? "")") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment