I'm wanting to build a menu interface programically by setting up a for
loop inside my main view controller which creates a bunch of buttons from a custom button class.
There are a few parameters I am passing to the button class, one of those is the action parameter for the addTarget
function.
self.addTarget(self, action: #selector(*****?*****), for: .touchUpInside)
I tried setting up an array of strings to pass to it but I get an error:
Cannot convert value of type 'String' to expected argument type 'Selector'
I tried creating an array of type Any
but the array values for the segue calls are confusing the compiler. So what kind of array can I make that can pass the type which is required by the #selector?
Issue
// Array declaration
var segueArray: [(Void)] = []
// Array initialisation
segueArray = [segueToDice1, segueToDice2, segueToDice3]
error Cannot assign value of type '[() -> ()]' to type '[(Void)]'