iOS - iOS 上的以下 LAContext 错误日志是什么意思?

问题描述

我的控制台中不断出现以下日志。

[Client,LAContext] LAContext[5174:1692] will keep returning Error Domain=com.apple.LocalAuthentication Code=-10 "Invalidated due to exceeded number of allocated contexts." UserInfo={NSLocalizedDescription=Invalidated due to exceeded number of allocated contexts.} from Now on.

有人可以帮忙吗?是什么导致了这个?

解决方法

听起来您正在创建多个 LAContext 对象,根据我自己对 12 Pro Sim 的测试,此错误发生在您有 65 个 LAContext 尚未失效之后。

LAContext 应该在发布时自动失效。也许您正在 ViewController 中实例化它,并且您的 ViewController 有一个保留周期,以防止 LAContext 被释放?

您可以通过在实例上调用 LAContext 来手动使 invalidate() 无效。