I define the below list swift class, and try to call the sfAuthenticateUser from the viewcontroller. But the Xcode intellisense list the wrong parameter type other than the type
The problem is that you try to call an instance function without having an actual instance at hand.
You either have to create an instance and call the method on that instance:
let instance = APISFAuthentication(...)
instance. sfAuthenticateUser(...)
or define the function as a class function:
class func sfAuthenticateUser(userEmail: String) -> Bool {
...
}
Explanation:
What Xcode offers you and what confuses you is the class offers the capability to get a reference to some of its instance functions by passing an instance to it:
class ABC {
func bla() -> String {
return ""
}
}
let instance = ABC()
let k = ABC.bla(instance) // k is of type () -> String
k
now is the function bla
. You can now call k
via k()
etc.