I'm using SSKeychain to store a session token. When I compile and run the app from XCode, sometimes the token cannot be found (seems like it works sporadically). However, if I unplug my device and run the app without XCode, the token is back, 10/10 times. I'm not sure if this is a problem with SSKeychain or with Keychain in general. The code I'm using to store and read values is the following:
- (void)setSecureValue:(NSString *)value forKey:(NSString *)key
{
[SSKeychain setPassword:value forService:kServiceName account:key];
}
- (NSString *)secureValueForKey:(NSString *)key
{
if (key != nil)
{
return [SSKeychain passwordForService:kServiceName account:key];
}
return nil;
}
Many issues revolving Keychain access seem to be resolved by realizing that the keychain is not a data storage and that it can be emptied at times (due to memory warnings, for example). However, since I always run on the same device, and the token is still there after unplugging and running again, I don't see how this could be the issue here.