Search code examples
swiftxcode11ios13

Syntax for UIAction on Xcode 11 beta 3


Xcode 11 beta 3 does not accept this code to instantiate UIAction anymore:

let action = UIAction(__title: "title", image: someImage, options: []) { _ in
    // some action
}

There's nothing in the documentation either.

I've found a post on Apple Developer Forums describing this same problem and the syntax that's now accepted, but it results in a runtime error:

let action = UIAction(__title: "title", image: someImage, identifier: nil, handler: { _ in
    // some action
}

+[UIAction actionWithTitle:image:identifier:handler:]: unrecognized selector sent to class 0x7fffa1b30178

There's also this new parameter identifier, but I couldn't find any documentation about how to use it.

Has anyone been able to successfully use UIAction with Xcode 11 beta 3?


Solution

  • I don't see where you're getting the options parameter from. This compiles and runs (no crash) on my machine using Xcode 11 beta 3:

        let action = UIAction(__title: "Howdy", image: nil, identifier: nil) {
            _ in
        }