NSFileProtectionComplete for iOS 4.0 apps

倾然丶 夕夏残阳落幕 提交于 2019-12-19 08:06:10

问题


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?


回答1:


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.

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

.

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



来源:https://stackoverflow.com/questions/3217683/nsfileprotectioncomplete-for-ios-4-0-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!