Asas12
Asas12

Reputation: 25

Swift typealias error

I'm starting to learning Swift and I'm currently following some tutorials and I'm stuck here with this problem.

After I declare this:

typealias LoginHandler = (_ msg: String) -› Void;

I got this error:

Tuple element cannot have two labels

I need this LoginHandler to have a message and retrieve void so I can use it in my login function to handle my Firebase errors.

typealias LoginHandler = (_ msg: String) -› Void;

class AuthProvider {
    private static let _instance = AuthProvider();

    static var Instance: AuthProvider {
        return _instance;
    }

    func login(withEmail: String, password: String, loginHandler: LoginHandler?){
        Auth.auth().signIn(withEmail: withEmail, password: password, completion:  {(user, error) in
            if error != nil {
            } else {
            }
        });
    }
}

So I have been trying different things but none of them have worked.

full code with errors

Upvotes: 0

Views: 673

Answers (2)

matt
matt

Reputation: 536057

This is not a correct function type declaration:

typealias LoginHandler = (_ msg: String) -› Void

You are using the wrong "greater than" symbol (unicode hex 203A).

Your code should look like this:

typealias LoginHandler = (_ msg: String) -> Void

Notice that difference in the second character making up the "arrow operator" (unicode hex 003E).

Upvotes: 3

Kevinosaurio
Kevinosaurio

Reputation: 2010

You only need to add a space after ">"

typealias LoginHandler = (_ msg: String) -> Void

Upvotes: 1

Related Questions