0
我一直在写一个嵌套函数,它接受touchID的原因字符串和一个布尔值(如果应该显示或不显示)。这是我的代码基本触摸ID实现
import UIKit
import LocalAuthentication
class XYZ : UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
presentTouchID(reasonToDsiplay: "Are you the owner?", true) //ERROR: Expression resolves to an unused function
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func presentTouchID(reasonToDsiplay reason: String, _ shouldShow: Bool) -> (Bool) ->(){
let reason1 = reason
let show = shouldShow
let long1 = { (shoudlShow: Bool) ->() in
if show{
let car = LAContext()
let reason = reason1
guard car.canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: nil) else {return}
car.evaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, localizedReason: reason) {(success, error) in
guard error != nil else {return}
dispatch_async(dispatch_get_main_queue(), { Void in
print("Kwaatle")
})
}
}
else{
print("Mah")
}
}
return long1
}
}
当我做 func viewDidLoad()
presentTouchID(reasonToDsiplay: "Are you the owner?", true)
我得到一个错误说
表达式解析为一个未使用的功能。
我在做什么错?
而@ luk2302,这也可以看作是一个完成处理程序正确删除布尔作为参数? – Dershowitz123
@ Dershowitz123是的,它是一个完成处理程序。 – luk2302
完美。这是否也是一个同步过程?因为我读过同步过程冻结了用户界面?我是我错了? @ luk2302? – Dershowitz123