I am using KeychainItemWrapper class(integrated .h and .m file in project) for saving passcode in Keychain for iOS App. Also imported "Security" Framework and "keychianItemWrapper.h" class in the project wherever it is needed.(#import , #import "KeychainItemWrapper.h" )
I am using below code in app delegate method for saving passcode in keychain access :
if([textfieldPassword1.text isEqual:textfieldPassword2.text]){
NSLog(@"CONGRATS !! PASSCODE MATCHED !!!");
//converting "textfieldPassword1" to NSNumber
NSNumber *textfieldPasscode1Num = [NSNumber numberWithInt:[textfieldPassword1.text intValue]];
//saving passcode to the keychain access
[keychain setObject:textfieldPasscode1Num forKey:(__bridge id)kSecValueData];
// [keychain setObject:[NSNumber numberWithInt:[textfieldPassword1.text intValue]] forKey:(__bridge id)kSecAttrAccount];
// if passcode matches then load Show Lock Screen Page
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] init];
[self.window addSubview:self.viewController.view];
[self.window makeKeyAndVisible];
}
AND HERE AM RESETTING PASSCODE USING BELOW CODE :
if(_isResetPasscode){
NSLog(@"Code here for Update Passcode in Keychain Access !!!");
_isResetPasscode = FALSE;
// "keychain" is object of "KeychainItemWrapper" class
[keychain resetKeychainItem];
/* Again setting the new passcode entered by user in keychain access.. IT IS NOT SAVING IN keychain access, where above the same line of code was working for saving passcode in keychain access
/*
[keychain setObject:resetPasscodeNum forKey:(__bridge id)kSecValueData];
NSLog(@"----Passcode Re-Setted ----!! %@\n",resetPasscodeNum);
}
When I am printing keychain passcode in console every time it is printing "0". Please guide me where i am doing wrong... Your help would be appreciated !!
Thanks in Advance