我观看了有关 NSFileProtectionComplete 和保护应用数据的 WWDC 2010 视频。
有什么例子吗?有没有人可以分享示例代码?
最佳答案
查看 NSFileManager 类文档:
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.
它基本上是单个文件的文件库。您只需在设置文件属性时传递常量即可。
To mark a file as protected, you must add an extended attribute to it. The Foundation framework includes two ways to add this attribute:
When writing the contents of an NSData object to disk using the writeToFile:options:error: method, include the NSDataWritingFileProtectionComplete option.
Use the setAttributes:ofItemAtPath:error: method of NSFileManager to add the NSFileProtectionKey attribute (with the NSFileProtectionComplete value) to an existing file
.
关于iphone - 适用于 iOS 4.0 应用程序的 NSFileProtectionComplete,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3217683/