最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]swift出错:Cannot invoke authenticateWithPassword with an argument list of type (String error inout NSError?)

Swift crifan 1793浏览 0评论

代码:

        var error: NSError?
        if (xmppStream!.authenticateWithPassword(password, error: &error) ) {
                  print("authentification successful")

        }

出错:

SwiftXMPP/AppDelegate.swift:140:25: Cannot invoke ‘authenticateWithPassword’ with an argument list of type ‘(String, error: inout NSError?)’

Expected an argument list of type ‘(String!)’

如图:

Cannot invoke authenticateWithPassword with an argument list of type String error inout NSError

搜:
swift Cannot invoke ‘authenticateWithPassword’ with an argument list of type ‘(String, error: inout NSError?)’
找到原型是:
- (BOOL)authenticateWithPassword:(NSString *)inPassword error:(NSError **)errPtr
{
所以去改为:
        do{
            if try xmppStream!.authenticateWithPassword(self.password) {
                print("authentification successful")
            }
        }catch{
            print("error")
        }
即可。

转载请注明:在路上 » [已解决]swift出错:Cannot invoke authenticateWithPassword with an argument list of type (String error inout NSError?)

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
85 queries in 0.163 seconds, using 22.08MB memory