What is the best way to save/load contents of array to file?

拥有回忆 提交于 2019-12-13 01:54:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!