KevinCork KevinCork - 4 years ago 393
AppleScript Question

How to write / read plist in Swift 3

I have an AppleScript setting up the data for my Swift App.

Let's say the data is saved on the desktop, for example data.plist.

How can I read this data from my Swift app and set as a variable?

Answer Source

You can use the NSDictionary API to read/write plist files. For example:

// given a value (fileURL) of type URL
// read plist
let nsDict = NSDictionary(contentsOf: fileURL)
// write plist
nsDict.write(to: fileURL, atomically: true)

NSDictionary Reference

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download