gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 12:14:27 27 4
gpt4 key购买 nike

我正在使用 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)
}
}

最佳答案

存储库的主分支包含以前版本的 Swift。自动转换后(当您第一次克隆项目并使用 Xcode 打开时,Xcode 会提示您转换为当前 Swift 语法),其中的 LockState 枚举PasscodeLockViewController 类变为:

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 中其他重复出现的相同类型错误,您必须分别更改它们。

关于ios - TouchiD 密码错误 "Type is ambiguous without more context",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45603142/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com