NSFileProtectionComplete for iOS 4.0 apps

后端 未结 1 508
清歌不尽
清歌不尽 2021-01-13 01:19

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条回答
  • 2021-01-13 01:47

    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

    0 讨论(0)
提交回复
热议问题