removeObjectForKey: gives "Could not store(Delete) string. Error was:-25300"
evgeniyd opened this issue · 4 comments
evgeniyd commented
Calling
[[PDKeychainBindings sharedKeychainBindings] removeObjectForKey:@"myKey"];
returns
Could not store(Delete) string. Error was:-25300
While investigating it, I've found that this is a custom NSLog
string, logged when the following operation fails:
OSStatus result=SecItemDelete((__bridge CFDictionaryRef)spec);
if (result!=0) {
NSLog(@"Could not store(Delete) string. Error was:%i",(int)result);
}
The error code from OSStatus
enum declared in <Security/SecBase.h>
has this description:
errSecItemNotFound = -25300, /* The specified item could not be found in the keychain. */
...which points out, that it's just the value being not found for respective key upon deleting.
Question
I wonder, what option here would be more preferable?
- I have to check for key existence, before attempting to delete it?
- The
PDKeychainBindingsController
has to have a fix to check the key, before deleting - The
PDKeychainBindingsController
has to have a fix to make error codes processing and logging more accurate - Ignore everything here (which was the way, it worked before this bug report was submitted)
evgeniyd commented
FYI. So far, my workaround:
if ([[PDKeychainBindings sharedKeychainBindings] objectForKey:@"myKey"]) {
[[PDKeychainBindings sharedKeychainBindings] removeObjectForKey:@"myKey"];
}
dhurley14 commented
danielkramer commented
Interesting, I've tried the testing for the existence of the key as you've suggested but I still get the same crash and error.
evgeniyd commented
@danielkramer hm, I do not have my app crashed upon the error. It is just the message, I don't prefer to be printed to the console.
Do you see the same log message?