Note that there are some explanatory texts on larger screens.

plurals
  1. PODouble KeyChainItemWrapper
    primarykey
    data
    text
    <p>I have a strange problem with the KeyChainItemWrapper.</p> <p>I used to create 2 of them like so:</p> <pre><code>KeychainItemWrapper *kcWrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"first" accessGroup:nil]; KeychainItemWrapper *kcWrapper1 = [[KeychainItemWrapper alloc] initWithIdentifier:@"second" accessGroup:nil]; </code></pre> <p>I would then set an object like this:</p> <pre><code>[kcWrapper setObject:@"something" forKey:(__bridge id)kSecValueData]; [kcWrapper1 setObject:@"something1" forKey:(__bridge id)kSecValueData]; </code></pre> <p>This worked perfectly, until... nothing changed?</p> <p>Now I get this error:</p> <pre><code>*** Assertion failure in -[KeychainItemWrapper writeToKeychain], /Users/wingair/Documents/iOSProjects/tulipstempelkort- ios/stempelkort/../KeychainItemWrapper.m:305 </code></pre> <p>Line 305 is:</p> <pre><code>// No previous item found; add the new one. result = SecItemAdd((__bridge CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL); NSAssert( result == noErr, @"Couldn't add the Keychain Item." ); </code></pre> <p>Been stuck here for quite some long time, any help is appreciated.</p> <p>The writeToKeyChain function:</p> <pre><code>- (void)writeToKeychain { CFDictionaryRef attributes = NULL; NSMutableDictionary *updateItem = nil; OSStatus result; if (SecItemCopyMatching((__bridge CFDictionaryRef)genericPasswordQuery, (CFTypeRef *)&amp;attributes) == noErr) { // First we need the attributes from the Keychain. updateItem = [NSMutableDictionary dictionaryWithDictionary:(__bridge NSDictionary *)attributes]; // Second we need to add the appropriate search key/values. [updateItem setObject:[genericPasswordQuery objectForKey:(__bridge id)kSecClass] forKey:(__bridge id)kSecClass]; // Lastly, we need to set up the updated attribute list being careful to remove the class. NSMutableDictionary *tempCheck = [self dictionaryToSecItemFormat:keychainItemData]; [tempCheck removeObjectForKey:(__bridge id)kSecClass]; [tempCheck removeObjectForKey:(__bridge id)kSecAttrAccessGroup]; // An implicit assumption is that you can only update a single item at a time. result = SecItemUpdate((__bridge CFDictionaryRef)updateItem, (__bridge CFDictionaryRef)tempCheck); NSAssert( result == noErr, @"Couldn't update the Keychain Item." ); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload