Skip to content

Commit fdc70db

Browse files
committed
Improved isSimple handling
1 parent e23049b commit fdc70db

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Demo/LTHPasscodeViewController Demo/LTHAppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3030
// [navController addChildViewController: demoController];
3131
self.window.rootViewController = navController;
3232
[self.window makeKeyAndVisible];
33-
33+
3434
// [LTHPasscodeViewController sharedUser].delegate = self;
3535
// [LTHPasscodeViewController useKeychain:YES];
3636
if ([LTHPasscodeViewController doesPasscodeExist] &&

LTHPasscodeViewController/LTHPasscodeViewController.m

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ - (void)_useKeychain:(BOOL)useKeychain {
166166

167167

168168
- (BOOL)_doesPasscodeExist {
169+
if ([LTHKeychainUtils getPasswordForUsername:_keychainPasscodeIsSimpleUsername
170+
andServiceName:_keychainServiceName
171+
error:nil]) {
172+
_isSimple = [[LTHKeychainUtils getPasswordForUsername:_keychainPasscodeIsSimpleUsername
173+
andServiceName:_keychainServiceName
174+
error:nil] boolValue];
175+
} else {
176+
_isSimple = YES;
177+
}
178+
169179
return [self _passcode].length != 0;
170180
}
171181

@@ -283,7 +293,6 @@ - (void)_savePasscode:(NSString *)passcode {
283293
updateExisting:YES
284294
error:nil];
285295

286-
287296
[LTHKeychainUtils storeUsername:_keychainPasscodeIsSimpleUsername
288297
andPassword:[NSString stringWithFormat:@"%@", [self isSimple] ? @"YES" : @"NO"]
289298
forServiceName:_keychainServiceName
@@ -429,7 +438,7 @@ - (void)setDigitsCount:(NSInteger)digitsCount {
429438
}
430439

431440
_digitsCount = digitsCount;
432-
441+
433442
// If we haven't loaded yet, do nothing,
434443
// _setupDigitFields will be called in viewDidLoad.
435444
if (!self.isViewLoaded) { return; }
@@ -693,7 +702,7 @@ - (void)_setupDigitFields {
693702
[_digitTextFieldsArray addObject:digitTextField];
694703
[_simplePasscodeView addSubview:digitTextField];
695704
}
696-
705+
697706
[self.view setNeedsUpdateConstraints];
698707
}
699708

@@ -1602,16 +1611,6 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
16021611

16031612

16041613
- (void)_commonInit {
1605-
if ([LTHKeychainUtils getPasswordForUsername:_keychainPasscodeIsSimpleUsername
1606-
andServiceName:_keychainServiceName
1607-
error:nil]) {
1608-
_isSimple = [[LTHKeychainUtils getPasswordForUsername:_keychainPasscodeIsSimpleUsername
1609-
andServiceName:_keychainServiceName
1610-
error:nil] boolValue];
1611-
} else {
1612-
_isSimple = YES;
1613-
}
1614-
16151614
[self _loadDefaults];
16161615
}
16171616

@@ -1634,6 +1633,7 @@ - (void)_loadMiscDefaults {
16341633
_slideAnimationDuration = 0.15;
16351634
_maxNumberOfAllowedFailedAttempts = 0;
16361635
_usesKeychain = YES;
1636+
_isSimple = YES;
16371637
_displayedAsModal = YES;
16381638
_hidesBackButton = YES;
16391639
_hidesCancelButton = YES;

0 commit comments

Comments
 (0)