代码:
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!)’
如图:
搜:
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?)