title: iOS Keychain occasionally return empty string
body: <p>I write very secure application (for Bank) and I keep the private key in the Keychain.
  I keep the Private key using the following code:</p>
  
  <pre><code>+(void)savePrivatekey:(NSString *)Key
  {
      KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"pKey" accessGroup:nil];
      [keychain setObject:Key forKey:(id)kSecValueData];
      [keychain release];
  }
  </code></pre>
  
  <p>and for get the private key using the following code:</p>
  
  <pre><code>+(NSString *)privateKey
  {
      KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"pKey"accessGroup:nil];
      NSString *privateKey = [keychain objectForKey:(id)kSecValueData];
      [keychain release];
      return privateKey;
  }
  </code></pre>
  
  <p>i don't save the private key in local variable from security reasons.
  because every call to server I need the private key i call to to function
  "GetPrivateKey" a lot of times.
  Maybe that's why sometimes i get from the keychain empty string.
  i can't  think of why this might happen.
  I noticed that in most cases this happens when the application return from background but no only...
  thanks...</p>
  
  <p>I opened ticket at Apple's engineers and they responded to me:</p>
  
  <p>Are you setting the kSecAttrAccessible attribute when you create the keychain item initially?</p>
  
  <p>I always create the same shape keychain:
  KeychainItemWrapper * keychain = [[KeychainItemWrapper alloc] initWithIdentifier: @ "pKey" accessGroup: nil];</p>
  
  <p>Does anyone know what their intent?
  thanks...</p>