You need to do something like this:
do {
try laContext.canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics)
} catch {
print("Cannot evaluate policy, error: \(error)")
}
All methods that returned Booland have inout NSError?as the last parameter were automatically converted (Swift 2) to throw an error, so the parameter was deleted. It Boolwas also redundant as it was equal to inout NSError?nil
EDIT: for more error information, use this in catch:
switch LAError(rawValue: error.code)! {
case .AuthenticationFailed:
break
case .UserCancel:
break
case .UserFallback:
break
case .SystemCancel:
break
case .PasscodeNotSet:
break
case .TouchIDNotEnrolled:
break
default:
break
}
(You can see all possible errors by clicking CMD on LAError
EDIT: XCode 7 beta 5/6 , NSErrorPointer ( NSURL checkResourceIsReachableAndReturnError ). LAContext, , , :
extension LAContext {
func canEvaluatePolicyThrowing(policy: LAPolicy) throws {
var error : NSError?
canEvaluatePolicy(policy, error: &error)
if let error = error { throw error }
}
}