There are some FileProtection
options you can set when writing an NSData
to disk:
NSDataWritingFileProtectionComplete
NSDataWritingFileProtectionNone
)
as well as an extended attribute, NSFileProtectionKey
, you can set on pre-existing files on disk via NSFileManager
:
NSFileProtectionComplete
NSFileProtectionNone
The app delegate is also informed of when your application is (not) going to be able to access protected data:
-applicationProtectedDataDidBecomeAvailable:
-applicationProtectedDataWillBecomeUnavailable:
All the gory details of encrypting and securing the data are handled by the hardware and OS on your behalf. It's fire-and-forget protection that kicks in whenever the device locks.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…