Andrey M. Andrey M. - 1 year ago 180
Swift Question

Facebook FBSDKLoginButtonDelegate loginButton function syntax error

i'm using Xcode8 and swift 3. So I fully converted my project to the latest syntax and now i get the error:

'Error' is ambiguous for type lookup in this context

in the function:

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
//do stuff

The function in FBSDK declared as follows:

- (void) loginButton:(FBSDKLoginButton *)loginButton
didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
error:(NSError *)error;

so I tried to change Error type to NSError but i get the other error:

'SignInViewController' does not conform to protocol 'FBSDKLoginButtonDelegate'

I don't know what to do. Any help is appreciated!

Answer Source

I found that i've imported RealmSwift that have their own Error struct. So the solution is to use Swift.Error instead of just Error. Hope this helps to anybody.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download