I\'m trying to get if Face ID or Touch ID succeeded in the function below
func authenticate() -> Bool{
let context = LAContext()
var error: NSErr
You should use a closure to obtain results of evaluation. Note that the return value for canEvaluatePolicy is a Bool but there is no return value for evaluatePolicy as it accepts a closure.
You can modify your method to include a closure instead of return.
func authenticate(completion: ((Bool) -> ())) {
...
completion(true) // false if it failed.
...
}
In other parts of your app, where you earlier used a return value you would now have to use a closure like:
class Foo {
func test() {
let isEvaluated = self.authenticate() // Old way
self.authenticate { success in
// bool will now indicate whether evaluation was done successfully or not.
}
}
}