Skip to content

Instantly share code, notes, and snippets.

@olivaresf
Last active August 24, 2020 05:33
Show Gist options
  • Select an option

  • Save olivaresf/e71b0e8b2da673a80283de5994d9b1fe to your computer and use it in GitHub Desktop.

Select an option

Save olivaresf/e71b0e8b2da673a80283de5994d9b1fe to your computer and use it in GitHub Desktop.
class SettingViewControllerActionDecider : SettingViewControllerProtocol {
private let PasswordProtectedKey = "front"
var isPasswordProtected: Bool {
get {
guard let front = UserDefaults.standard.object(forKey: PasswordProtectedKey) as? Bool else { return false }
return front
}
set {
UserDefaults.standard.set(newValue, forKey: PasswordProtectedKey)
}
}
func validate(password: String?, confirmPassword: String?, from: SettingViewController) -> Bool {
guard
let givenPassword = password,
let givenConfirmedPassword = confirmPassword else {
print("The password is not equal")
return false
}
return givenPassword == givenConfirmedPassword
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment