问题
I have a Swift application where I have an NSTableView populated by an array of custom structs, which contains an NSSound property. My question is, what is the best way to save the content of this array to a file, and how would I load the array from said file?
回答1:
Save the content to a file with:
NSKeyedArchiver.archiveRootObject(rootObject: AnyObject, toFile: String)
Load the array with:
NSKeyedUnarchiver.unarchiveObjectWithFile(path: String)
来源:https://stackoverflow.com/questions/31523726/what-is-the-best-way-to-save-load-contents-of-array-to-file