2010-07-10 8 views
5

Я увидел видео WWDC 2010 о NSFileProtectionComplete и защитил данные приложения.NSFileProtectionComplete для приложений iOS 4.0

Есть ли у вас какие-либо примеры? Есть ли у кого-нибудь образец кода для обмена?

+0

Вы должны быть осторожны с этим. Это хороший способ стрелять в ногу, потому что система может сделать файлы нечитаемыми во время их выбора. – TechZen

+0

Документация по этому вопросу, TechZen? – memmons

ответ

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

+0

Если я установил это поведение в файл каталога документов. Можно ли получить доступ к файлу в iDevice Locked State? @TechZen – iTag

Смежные вопросы