目前,我一直在使用XCode 8并在线
let range = key.startIndex...key.startIndex.advancedBy(0)
Run Code Online (Sandbox Code Playgroud)
我收到错误:
错误:'advancedBy'不可用:要将索引前进n步,请在生成索引的CharacterView实例上调用'index(_:offsetBy :)'.
我怎样才能解决这个问题?
错误的屏幕截图如下:
我正在将下面的代码转换为Swift 3.
if context.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error:nil) {
// 2.
context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics,
localizedReason: "Logging in with Touch ID",
reply: { (success : Bool, error : NSError? ) -> Void in
// 3.
dispatch_async(dispatch_get_main_queue(), {
if success {
self.performSegueWithIdentifier("dismissLogin", sender: self)
}
if error != nil {
var message : NSString
var showAlert : Bool
// 4.
switch(error!.code) {
Run Code Online (Sandbox Code Playgroud)
步骤4在Xcode 8,Swift 3上不再起作用.所以我不能做以下情况:
switch(error!.code) {
case LAError.AuthenticationFailed.rawValue:
message = "There was a problem verifying your identity."
showAlert = true
break;
Run Code Online (Sandbox Code Playgroud)
目前,似乎还没有我能找到的解决方案.有任何建议,请告诉我.
非常感谢!