iphone write to file fails

后端 未结 2 1917
不思量自难忘°
不思量自难忘° 2020-12-22 10:05

I\'m writing some data to a plist file but it fails on the device but not in the simulator. I\'m lost, don\'t know where to look for a solution.

This is my code:

相关标签:
2条回答
  • 2020-12-22 10:35

    This fails on the device because you cannot write to the application's bundle folder, only to the /tmp, Documents, and Cache folders. If users were able to modify the bundle, the digital signature for the app would no longer be valid and no one would be able to reliably obtain your intact app from the App Store and run it.

    This works on the simulator, however, because your operating system will let you write to pretty much anywhere in your home folder, including the application bundle folder. OS X functionality is not restricted in the same way iOS's is restricted.

    This is part of iOS's sandbox approach to security. The solution is to write to the /tmp, Documents or Cache folder, instead.

    0 讨论(0)
  • 2020-12-22 10:51

    Why are you trying to write in resource directory? Have you checked this?

    0 讨论(0)
提交回复
热议问题