How to pass in parameters into @objc function

前端 未结 2 888
野趣味
野趣味 2020-12-21 21:07

I have a cell in a tableView, with a button I want to add an action to.

The button will be an email address. When the button is pressed, I want to trigger a delegate

2条回答
  •  一生所求
    2020-12-21 21:27

    You cannot pass anything into a target's action method. You don't call the method; the target-action architecture calls it when the button is tapped. The action method must take one parameter, namely the sender (which in this case will be the button).

    If the action method needs more information at the time that it is called, you must provide that information in some other way, e.g. as an instance property that the action method can access when it is called.

提交回复
热议问题