title: How can I protect data using iOS on-disk encryption when the user passcode lock has not been enabled?
body: <h2>Question</h2>
  <p>How can I ensure data is encrypted when using NSData.writeToFile:options:error: with the <strong>NSDataWritingFileProtectionComplete</strong>?</p>
  <h2>Background research: Enabling data encyption</h2>
  <p>According to Apple documentation:</p>
  <blockquote>
  <p>Data protection is available on most iOS devices and is subject to
  the  following requirements:</p>
  <ul>
  <li><p>The file system on the user’s device must support data protection.  This is true for newer devices, but for some earlier devices, the user
  might have to reformat the device’s disk and restore any content from
  a backup.</p>
  </li>
  <li><p><strong>The user must have an active passcode lock set for the  device.</strong></p>
  </li>
  </ul>
  </blockquote>
  <p><a href="https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW11" rel="noreferrer">https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW11</a></p>
  <p>The requirements state that user <strong>must</strong> activate passcode lock for the device, this is reinforced by the following end user documentation:</p>
  <p>Enable data protection by configuring a passcode for your device:</p>
  <ol>
  <li>Tap Settings &gt; General &gt; Passcode.</li>
  <li>Follow the prompts to create a passcode.</li>
  <li>After the passcode is set, scroll down to the bottom of the screen and verify that the text &quot;Data protection is enabled&quot; is visible.</li>
  </ol>
  <p><img src="https://i.stack.imgur.com/DSsEP.png" alt="Passcode lock screen" /></p>
  <p><a href="http://support.apple.com/kb/HT4175" rel="noreferrer">http://support.apple.com/kb/HT4175</a></p>
  <h3>Similar SO Questions:</h3>
  <p><a href="https://stackoverflow.com/questions/3806455/how-can-i-find-out-if-the-iphone-user-currently-has-a-passcode-set-and-encryptio">How can I find out if the iPhone user currently has a passcode set and encryption enabled?</a> seems like the answer to this question is no longer valid.</p>