How to put a Property List in the Documents folder

2019-08-22 02:44发布

问题:

I have several tableviews in my app and the data source for each tableview is a property list. Currently I have the propertylists saved in the application bundle. However, thats only because I created them in XCode and they are automatically saved in the documents folder. This is fine as when the app ships, thats where they need to be.

However, I would like to put a copy of the property lists in the documents folder of my app as well when it ships. How can I do that? I mean Can I program XCode to save the pLists I create manually to save in the documents folder of my app? Or how does that work? Basically to summarize, I would like to put a copy of the propertylist each in the application bundle and the documents folder

I appreciate any help anyone provides.

Thanks

回答1:

You can't. You would have to copy the file over when the app is first run, either by detecting that the file doesn't exist or by checking a flag in NSUserDefaults.