密码有 TouchiD 错误 "Type is ambiguous without more context"

Passcode with TouchiD Error "Type is ambiguous without more context"

我正在使用 github 的一些代码并尝试将其转换为 Swift 3.0。到目前为止,我已经完成了所有工作,但是我在代码的 3 行中遇到了这个错误:

Type of expression is ambiguous without more context

下面我标记了被这个错误标记的行。我该如何解决这个问题?我所知道的其他一切都有效。在修复之前我无法测试演示本身。

//
//  PasscodeSettingsViewController.swift
//  PasscodeLockDemo
//
//  Created by Yanko Dimitrov on 8/29/15.
//  Copyright © 2015 Yanko Dimitrov. All rights reserved.
//

import UIKit
import PasscodeLock

class PasscodeSettingsViewController: UIViewController {
    @IBOutlet weak var passcodeSwitch: UISwitch!
    @IBOutlet weak var changePasscodeButton: UIButton!
    @IBOutlet weak var testTextField: UITextField!
    @IBOutlet weak var testActivityButton: UIButton!

    fileprivate let configuration: PasscodeLockConfigurationType

    init(configuration: PasscodeLockConfigurationType) {
        self.configuration = configuration

        super.init(nibName: nil, bundle: nil)
    }

    @IBAction func passcodeSwitchValueChange(_ sender: UISwitch) {
        let passcodeVC: PasscodeLockViewController

        if passcodeSwitch.isOn {
            // Error on next line
            passcodeVC = PasscodeLockViewController(state: .SetPasscode, configuration: configuration)
        } else {

            // Error on next line
            passcodeVC = PasscodeLockViewController(state: .RemovePasscode, configuration: configuration)

            passcodeVC.successCallback = { lock in

                lock.repository.deletePasscode()
            }
        }

        present(passcodeVC, animated: true, completion: nil)
    }

    @IBAction func changePasscodeButtonTap(_ sender: UIButton) {
        let repo = UserDefaultsPasscodeRepository()
        let config = PasscodeLockConfiguration(repository: repo)

        let passcodeLock = PasscodeLockViewController(state: .ChangePasscode, configuration: config) 

        // Error on next line
        presentViewController(passcodeLock, animated: true, completion: nil)
    }
}

repo 的 master 分支包含 Swift 的先前版本。自动转换后(当你第一次克隆项目并用Xcode和Xcode打开时提示你转换为Current Swift语法) PasscodeLockViewController class 中的 LockState 枚举变为:

public enum LockState {
    case enterPasscode
    case setPasscode
    case changePasscode
    case removePasscode

    func getState() -> PasscodeLockStateType {

        switch self {
        case .enterPasscode: return EnterPasscodeState()
        case .setPasscode: return SetPasscodeState()
        case .changePasscode: return ChangePasscodeState()
        case .removePasscode: return EnterPasscodeState(allowCancellation: true)
        }
    }
}

在您实例化的演示项目中,您使用的是:(此处枚举大小写为 大写.SetPasscode

passcodeVC = PasscodeLockViewController(state: .SetPasscode, configuration: configuration)

您必须将此初始化更改为:

passcodeVC = PasscodeLockViewController(state: .setPasscode, configuration: configuration)

而对于Xcode中其他重复出现的同类型错误,您必须分别更改它们。