标签:style blog io ar os sp on div 2014
import LocalAuthentication
var myContext = LAContext()
var error: NSError?
var localizedReasonString = "认证提示信息"
if myContext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &error) {
//第三个参数为闭包
myContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: localizedReasonString, reply: {
(success: Bool, error: NSError!) in
if success {
//认证成功
} else {
//认证失败,错误原因在error中
}
})
} else {
//不能够进行认证,错误信息在error中
}LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = "认证提示信息";
if ([myContext canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics error: &authError]) {
[myContext evaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason: myLocalizedReasonString reply: ^(BOOL success, NSError *error) {
if (success) {
//认证成功
} else {
//认证失败,error里包含错误信息
}
}]
} else {
//不能进行认证, authError中包含错误信息
}标签:style blog io ar os sp on div 2014
原文地址:http://blog.csdn.net/mobilecode/article/details/41311535