title: iOS5: How can I find out if the iPhone user currently has a passcode set and encryption enabled?
body: <p>Seems to me, that the iOS 4 hint (<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>)  does not work any more. I want make sure that user has chosen a passcode before he can use my app, but I did not find any way in iOS5 to find that out. Creating a file and comparing like this</p>
  
  <pre><code> BOOL fileProtectionEnabled = [NSFileProtectionNone isEqualToString:[testFileAttributes objectForKey:NSFileProtectionKey]];
  </code></pre>
  
  <p>does not make a difference in an locked and a unlocked device.</p>
  
  <p>I also tried to create a file like this</p>
  
  <pre><code>[[NSFileManager defaultManager] createFileAtPath:documentFile contents:[@"super secret file contents" dataUsingEncoding:NSUTF8StringEncoding] attributes:[NSDictionary dictionaryWithObject:NSFileProtectionCompleteUntilFirstUserAuthentication forKey:NSFileProtectionKey]];
  </code></pre>
  
  <p>expecting that the documentFile would only be created when there is a passcode, but it's also created without a passcode.</p>