如何将数据保护类权利添加到我的 iOS 5 应用程序
我已经浏览了整个网络,包括苹果的开发网站,但我找不到任何有关如何设置应用程序的 /Documents 目录属性 NSFileProtectionKey = NSFileProtectionComplete 的说明。我已经在应用程序第一次运行时设置了该值,但是有没有办法以其他方式设置它?就像通过一些 X 代码复选框、plist 或其他。
另请注意:存储在数据保护类别为 NSFileProtectionComplete 的目录下的任何文件是否会自动被视为与其目录相同的保护类别?
非常感谢,
菲什
I have been all over the web including Apple's dev site but I can't find any instruction on how to set an app's /Documents directory attribute NSFileProtectionKey = NSFileProtectionComplete. I have set the value upon the first time the app runs but is there a way to set it otherwise? Like through some X-Code check box, plist, or other.
Also on a related note: Are any files stored under a directory with the data protection class of NSFileProtectionComplete automatically treated as the same protection class as its directory?
Thanks a bunch,
Fissh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要保护应用程序 Documents 目录中的文件,无需任何代码,您必须向应用程序添加 entitlements.plist。
在 entitlements.plist 中,添加“DataProtectionClass”键和“NSFileProtectionComplete”值。只要设备锁定,您的文件就会自动受到保护。
这是一个例子
To protect files in your application Documents directory, without any code, you have to add an entitlements.plist to your application.
In your entitlements.plist, add the "DataProtectionClass" key, with the "NSFileProtectionComplete" value. Your files will be automatically protected as long as the device is locked.
Here is an example
WWDC 会议 208 对此进行了轻松讨论,我认为您可以使用该密钥创建一个权利文件,并且不需要编写代码。
我还没有这样做,所以我不完全确定它是否有效。
WWDC session 208 breezed over this, I think you create an entitlements file with that key, and you don't need to write code.
I haven't done this yet so I'm not completely sure it works.
这是我想出的技巧,直到我弄清楚如何正确设置 /Documents 目录保护。
我只是在加载应用程序时调用上面的代码,以设置文档目录保护(如果尚未设置)。
菲什
This is the hack I came up with until I figure out how to set the /Documents directory protections correctly.
I just call the above code upon loading of the app, to set the documents directory protection if it is not set already.
Fissh
http://devforums.apple.com/message/627887
开发者论坛:Apply DataProtectionClass Entitlement
我找到了此链接,并且此 Entitlements 方法当前不起作用并针对错误问题进行了归档,因此我们必须逐个文件进行操作。
http://devforums.apple.com/message/627887
Developer Forums: Apply DataProtectionClass Entitlement
I found this link, and this Entitlements method currently not working and filed for the bug issue, so we would have to do file by file.