2010-07-10 69 views
5

我看到了有關NSFileProtectionComplete的WWDC 2010視頻並保護了應用程序的數據。針對iOS 4.0應用程序的NSFileProtectionComplete

有沒有什麼例子呢?是否有人有示例代碼分享?

+0

您需要注意這一點。這是一個很好的方法,因爲系統可以在選擇時渲染文件不可讀。 – TechZen 2010-07-10 17:13:37

+0

關於這個的文檔,TechZen? – memmons 2011-05-21 13:46:36

回答

10

見的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

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

+0

嘿,我很着急,所以你可以請我解釋一下NSFileProtetionKey對文件做了什麼? – satheeshwaran 2013-04-24 02:51:59

+0

如果我將此行爲設置爲Documents目錄文件。是否可以訪問iDevice Locked State上的文件? @TechZen – iTag 2014-04-09 08:25:00

相關問題