Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AuthManager {
- var callbackVar: (() -> Bool)?
- func authenticateUser(username: String, password: String, isAuth: @escaping () -> Bool) {
- let validCredentials = [
- "user1": "password1",
- "user2": "password2",
- "user3": "password3"
- ]
- let authenticated = validCredentials[username] == password
- callbackVar = isAuth
- if callbackVar != nil {
- let success = callbackVar!()
- if success {
- print("Authentication successful")
- } else {
- print("Authentication failed")
- }
- }
- }
- }
- let authManager = AuthManager()
- let callback: () -> Bool = {
- return true
- }
- authManager.authenticateUser(username: "user1", password: "password1", isAuth: callback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement