Which iOS NSFileProtection class should a developer choose for a file that must remain readable while the app processes background uploads even after the device is locked by the user?
- A.A) NSFileProtectionComplete
- B.B) NSFileProtectionCompleteUnlessOpen
- C.C) NSFileProtectionCompleteUntilFirstUserAuthentication
- D.D) NSFileProtectionNone
Why B is correct
NSFileProtectionCompleteUnlessOpen keeps a file accessible as long as it was opened before the lock; it stays open for background tasks even after the screen locks. NSFileProtectionComplete (A) revokes access immediately on lock, breaking background uploads. NSFileProtectionCompleteUntilFirstUserAuthentication (C) is accessible after first unlock until reboot but does not distinguish whether the file is open. NSFileProtectionNone (D) offers no protection and is the wrong choice for sensitive files.
Know someone studying for Mobile Security Fundamentals? Send them this one.