在 UITextField 中调用 viewDidLoad

Calling viewDidLoad in UITextField

在UITextField中调用viewDidLoad的代码是什么,我好像只找到了五花八门的答案:

    @IBOutlet weak var providerForm: UITextField!

// 这里插入什么来调用viewDidLoad函数?

    override func viewDidLoad() {
    super.viewDidLoad()

    self.viewDidLoad()
    self.blockchain = Blockchain(genesisBlock: genesisBlock)
    // Do any additional setup after loading the view.
    self.generateDummyTransactions()
    self.providerForm = providerForm
    self.destinatorForm = destinatorForm
    self.amountSum = amountSum

func generateDummyTransactions() {



    let transaction = Transaction(from: "Mary", to: "Steve", amount: 20.0, transactionType: TransactionType.domestic)
    let block1 = Block()
    block1.addTransaction(transaction: transaction)
}

sendButton's IBAction 方法中调用 generateDummyTransactions(),然后在那里获取 textField's text,即

class VC: UIViewController {
    @IBOutlet weak var providerForm: UITextField!

    @IBAction func onTapSendButton(_ sender: UIButton) {
        self.generateDummyTransactions()
    }

    func generateDummyTransactions() {
        if let text = self.providerForm.text {
            //use text here...
        }
    }
}