【发布时间】:2016-06-12 07:01:13
【问题描述】:
我一直想写一个嵌套函数,它接受 touchID 的原因字符串和一个 bool 值(如果它应该显示或不显示)。这是我的代码
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
}
}
当我在presentTouchID(reasonToDsiplay: "Are you the owner?", true)
func viewDidLoad() 我收到一条错误消息
表达式解析为未使用的函数。
我做错了什么?
【问题讨论】: