Facebook FBSDKLoginButtonDelegate loginButton func

2019-06-14 18:56发布

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!

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-06-14 19:35

The syntax in FBSDKLoginButtonDelegate method is changed like below in Swift 3.

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


    }

"didCompleteWithResult result" is changed to "didCompleteWith result".

查看更多
相关推荐>>
3楼-- · 2019-06-14 19:44

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.

查看更多
登录 后发表回答