Valid file path for archiverootobject and unarchiverootobject

后端 未结 1 1036
孤独总比滥情好
孤独总比滥情好 2020-11-28 16:51

I am making an iPhone app and in a previous question I was told that I needed a valid file path for archiverootobject and unarchiverootobject but I don\'t know how to make o

相关标签:
1条回答
  • 2020-11-28 17:37

    You can save it to a subdirectory folder named with your bundleID inside the application support folder or you can also save it to the preferences folder located inside the library directory:

    let preferencesDirectoryURL = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first!.appendingPathComponent("Preferences", isDirectory: true)
    let fileURL = preferencesDirectoryURL.appendingPathComponent("fileName.plist")
    print(fileURL.path)   // "/var/folders/.../Library/Preferences/fileName.plist
    
    0 讨论(0)
提交回复
热议问题