Not sure if this is possible with swift, so here goes.
I have a string array , these are defined by the user, ie, NO a priori knowledge
for toolbar 1, arrayA:[String]=["f1", "f2", "f3".....]
for toolbar 2, arrayB:[String] =["f3", "f10", "f22"...]
I have a database of functions or matrix if you like for the functions.
to create a bunch of UIButtons is no big deal just loop through a class to define UIButtons, now the tricky part, I want to define actions take for each button as the array value.
a[0]-> create button, name it "f1", set a background image "f1.png", set a color, "f1" and call an action named f1
Keep in mind that Swift is a compiled language, and Perl is usually an interpreted language.
So you can take this sequence:
a[0]-> create button, name it "f1", set a background image "f1.png", set a color, "f1" and call an action named f1
go through and write code to perform each of those actions under the appropriate conditions (either as one statically coded sequence, or as a sequence of independent steps), and then have
a[x] -> a token or sequence of tokens
and then process those tokens to achieve dynamic behavior. Having all of the buttons use the same action handler, figure out which element of the array they are, and then process the proper sequence of tokens is entirely feasible.
But you've got to define the various behaviors ahead of time, you don't get to just put arbitrary strings in a database and call eval() to do arbitary things.