Is an iPhone app's document directory /var/mobile/Documents or /var/mobile/Library/AppName?

后端 未结 7 796
小蘑菇
小蘑菇 2020-12-21 00:34

As far as I know (and read everywhere) an application\'s documents directory should be somewhere in /var/mobile/Library/ on the iPhone but if I\'m logging the g

7条回答
  •  一向
    一向 (楼主)
    2020-12-21 00:58

    What you do is on app start, you check if the file you want in the docs dir exists, and if it doesn't, you copy it there from your read-only application bundle. Each successive time you launch the app, it's there. And, if for some stupid reason apple ever changes it, you don't have to adjust your code, since it's versatile enough to adapt to the change. It'll copy over the original data into the new location (which isn't optimal, but it's better than assuming it's in a static location, which would cause all sorts of confusion amongst your users, or worse: a crash).

提交回复
热议问题