我正在使用 github 上的一些代码并尝试将其转换为 Swift 3.0。到目前为止,我已经完成了所有工作,但是在代码的 3 行中出现了这个错误:
在没有更多上下文的情况下,表达式的类型是模棱两可的
下面我标记了被这个错误标记的行。我该如何解决这个问题?我所知道的其他一切都有效。在解决此问题之前,我无法测试演示本身。
//
// 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)
}
}