gpt4 book ai didi

swift3 - 错误 : Cannot use instance member within property initializer - Swift 3

转载 作者:行者123 更新时间:2023-12-04 18:59:40 26 4
gpt4 key购买 nike

当我编译以下代码时,出现错误“无法在属性初始化程序中使用实例成员 'AddEployeeName',属性初始化程序在 'self' 可用之前运行”。你能帮忙解决这个错误吗?该计划是为了让员工能够输入他们的姓名并拍照:

class AddEmployeeViewController: UITableViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate {

@IBOutlet weak var addEmployeeName: UITextField!
@IBOutlet weak var addEmployeeEmail: UITextField!
@IBOutlet weak var employeePhoto: UIImageView!

let employee: [String:AnyObject] = [

"name": addEmployeeName.text!,
"email": addEmployeeEmail.text!,

]

最佳答案

您不能调用addEmployeeName.text!在属性初始化器中。但是,您可以在 viewDidLoad 之类的方法中初始化“员工”

关于swift3 - 错误 : Cannot use instance member within property initializer - Swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40710909/

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