gpt4 book ai didi

ios - 将 Objective-C 选择器映射到 Swift

转载 作者:行者123 更新时间:2023-11-29 01:51:16 26 4
gpt4 key购买 nike

我正在使用适用于 IOS 的 Google Calendar API。我已经桥接它以便我可以快速使用它。授权工作一直很好,直到调用回调(即我可以在我的 Google 帐户中看到授权发生)。

their example他们有一个选择器来处理成功的身份验证,如下所示。

// Handle completion of the authorization process, and update the Google Calendar API
// with the new credentials.
- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)authResult
error:(NSError *)error {
//...
}

我已将此选择器翻译如下...

func finishedAuthorisation(viewController:GTMOAuth2ViewControllerTouch?, authResult:GTMOAuth2Authentication?, error:NSError?){
//...
}

...并像这样使用它...

GTMOAuth2ViewControllerTouch(scope: " ".join(scopes), clientID: kClientID, clientSecret: kClientSecret, keychainItemName: kKeychainItemName, delegate: self, finishedSelector: "finishedAuthorisation:")

...导致此错误

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSInvocation _invocationWithMethodSignature:frame:]: method signature argument cannot be nil'

我在这里做错了什么?

最佳答案

我用这个选择器 finishedAuthorisation:authResult:error: 解决了这个问题

实践中:

处理方法:

func finishedAuthorisation(viewController:GTMOAuth2ViewControllerTouch, authResult:GTMOAuth2Authentication, error:NSError?) {
...
}

以及我如何使用选择器:

GTMOAuth2ViewControllerTouch(scope: " ".join(scopes), clientID: kClientID, clientSecret: kClientSecret, keychainItemName: kKeychainItemName, delegate: self, finishedSelector: "finishedAuthorisation:authResult:error:")

关于ios - 将 Objective-C 选择器映射到 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31385130/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com