title: Save NSMutableDictionary in iOS Keychain using iOS 6+
body: <p>I am trying to save NSMutableDictionary in iOS keychain using KeychainItemWrapper classes. But I am not able to save it. I am getting error </p>
  
  <p>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't add the Keychain Item.'</p>
  
  <p>Here is my data to be saved</p>
  
  <pre><code>    {
      country = USA;
      id = 3;
      name = "Test User";
      photo = "http://www.mydomain.com/images/user1.jpg";
      result = true;
      "country" = 1;
  }
  </code></pre>
  
  <p>Here is my code</p>
  
  <pre><code>// Call to save 
  [self storeLoggedInUserInfoInKeychainWithDictionary:dict];
  
  
          -(void)storeLoggedInUserInfoInKeychainWithDictionary:(NSMutableDictionary*)dict
      {
          // Save Login Credentials
          KeychainItemWrapper* loginUserkeychain = [[KeychainItemWrapper alloc] initWithIdentifier:LOGIN_USER_SERVICE accessGroup:nil];
          NSString *error;
          [loginUserkeychain setObject:(__bridge id)(kSecAttrAccessibleWhenUnlocked) forKey:(__bridge id)(kSecAttrAccessible)];
          NSData *dictionaryRep = [NSPropertyListSerialization dataFromPropertyList:dict format:NSPropertyListXMLFormat_v1_0 errorDescription:&amp;error];
          [loginUserkeychain setObject:dictionaryRep forKey:(__bridge id)(kSecValueData)];
      }
  
      -(NSMutableDictionary*)fetchLoggedInUserInfoFromKeychain
      {
          KeychainItemWrapper* loginUserkeychain = [[KeychainItemWrapper alloc] initWithIdentifier:LOGIN_USER_SERVICE accessGroup:nil];
          NSString *error;
          //When the NSData object object is retrieved from the Keychain, you convert it back to NSDictionary type
          NSData *dictionaryRep = [loginUserkeychain objectForKey:(__bridge id)(kSecValueData)];
          NSDictionary *dictionary = [NSPropertyListSerialization propertyListFromData:dictionaryRep mutabilityOption:NSPropertyListImmutable format:nil errorDescription:&amp;error];
          if (error) {
              NSLog(@"%@", error);
          }
          return [NSMutableDictionary dictionaryWithDictionary:dictionary];
      }
  
      -(void)resetLoggedInUserInfoFromKeychain
      {
          KeychainItemWrapper* loginUserkeychain = [[KeychainItemWrapper alloc] initWithIdentifier:LOGIN_USER_SERVICE accessGroup:nil];
          [loginUserkeychain resetKeychainItem];
      }
  </code></pre>
  
  <p>Can anybody tell me whats wrong in above code ?
  Thanks in advance.</p>