plist writing data inside dictionary

泄露秘密 提交于 2019-12-02 07:30:34

In your app bundle, no: you can't write files inside your app bundle.

However, you can copy the file to the Documents or Library directory of the app sandbox upon the first launch on your app, then edit the plist file from there -- wheter it was created by code or by hand is unimportant.

bkbeachlabs

I did something like this in my app. I created a plist which was basically a bunch of levels for my game. Each level was an array, with a whole bunch of different attributes like NSNumbers and NSStrings, etc. I add the original plist to my app bundle, but then when the user first launches the app, I create a copy of the plist and store it as a dictionary with Core Data. Then I can load and save all my data into the Core Data copy of the plist.

All the changes you make to the plist are saved in the Core Data, but the original plist is unchanged, so you have to make sure that once you have a saved game file, you load that instead of the plist. the plist only ever gets read once.

try with this link. You can update the values in plist as will as add & delete too.

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