Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Can we use UIAction on UIButton controls created with Codea’s ObjC bridge as handlers?

in Questions Posts: 130

While awaiting delegate functionality in Codea’s ObjC bridge, I was wondering if it was currently possible to use the UIAction Class with UIButton as simple control handlers as suggested in this example from an online Swift tutorial:

class ViewController: UIViewController {
private let someActivity: SomeActivity

override func viewDidLoad() {
    let signUpAction = UIAction(
        title: "Sign Up",
        image: UIImage(systemName: "sign.up"),
        handler: { [someActivity] _ in

    let signUpButton = UIButton(primaryAction: signUpAction)


From what I understood, the “primaryAction” method for UIButton invokes the UIAction handler block whenever the UIButton is touched. That would seem an easy way to create simple GUI buttons in Codea with ObjC. However, I tried playing around with the above example to create a simple button and tried converting the above Swift code to Codea’s Objc format but couldn’t seem to format the handler block of code correctly to get UIButton to accept the handler in its primaryAction method (e.g. with signUpButton = UIButton:primaryAction_(signUpAction), signUpAction was considered an invalid argument).

Should UIAction be able to work as a handler for a UIButton in the latest Codea release? If so, can anyone provide a sample snipped of code that I could use to try out that functionality in my app? If not, I will look for other handler solutions and await an upcoming Codea release that supports delegates.

Thank you.

Sign In or Register to comment.