1

我有一个应用程序需要在运行之间保留数据。我一直在为此使用 NSUserDefaults,但有一些用户向我指出了这一点:这会导致不同的用户最终得到不同的数据,这不是应用程序应该工作的方式。它需要一个可以读取/写入的目录,无论哪个用户正在运行它。

因此,我需要一个沙盒 mac 应用程序可以读取和写入的非用户特定目录。

谢谢!

(哦,如果这个目录在我的应用程序更新之间是持久的,那也很有帮助!)

快速几乎不相关的问题:有没有办法在 Mac App Store 批准的应用程序中拥有用户可修改的资源文件?我不希望它可以通过我的应用程序进行修改;我只是想确保修改它的用户不会因为不匹配代码签名哈希或其他东西而导致系统终止应用程序。

4

1 回答 1

1

I don't think that you will be able to read and write in a directory outside of the App Sandbox container without prompting the user to select it using Powerbox and saving a security-scoped bookmark (see App Sandbox Container Directory). From what I've gathered about App reviews lately, you won't even be able to specify a default in the open dialog if you elect to have the user choose the directory.

As for the second question, as I understand it any verification of code signatures is left to the developer. So while MAS apps have a _CodeSignature folder containing a plist with all the hashes of the resource, in my experiments changing them had no effect on app launch.

于 2012-06-14T17:20:00.813 回答