适用于iOS 4.0应用程序的NSFileProtectionComplete [英] NSFileProtectionComplete for iOS 4.0 apps

查看:146
本文介绍了适用于iOS 4.0应用程序的NSFileProtectionComplete的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了一个关于NSFileProtectionComplete的WWDC 2010视频并保护了应用程序的数据。

I saw a WWDC 2010 video about NSFileProtectionComplete and protecting app's data.

那里有没有例子?有没有人可以分享样本代码?

Are there any examples out there? Does any one have sample code to share?

推荐答案

请参阅NSFileManager类doc:

See the NSFileManager class doc:


该文件以加密的
格式存储在磁盘上,并且无法从
读取或在设备为
锁定或启动时写入。

The file is stored in an encrypted format on disk and cannot be read from or written to while the device is locked or booting.

它基本上是单个文件的文件库。您只需在设置文件属性时传递常量。

It's basically file vault for individual files. You just pass the constant when you set the file attributes.


要将文件标记为受保护,您必须为
添加扩展属性。
Foundation框架包含两种方式
来添加此属性:

To mark a file as protected, you must add an extended attribute to it. The Foundation framework includes two ways to add this attribute:

使用以下方法将NSData
对象的内容写入磁盘时
writeToFile:options:error:方法,
包括
NSDataWritingFileProtectionComplete
选项。

When writing the contents of an NSData object to disk using the writeToFile:options:error: method, include the NSDataWritingFileProtectionComplete option.

使用
setAttributes:ofItemAtPath:error:
NSFileManager的方法,用于将
NSFileProtectionKey属性(
NSFileProtectionComplete值)添加到
现有文件

Use the setAttributes:ofItemAtPath:error: method of NSFileManager to add the NSFileProtectionKey attribute (with the NSFileProtectionComplete value) to an existing file

http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StandardBehaviors/StandardBehaviors.html

这篇关于适用于iOS 4.0应用程序的NSFileProtectionComplete的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆