I'm trying to accomplish the following task (using the playground): store in an array a list of functions and later execute them.
What I'm doing is:
func f1(){
println("f1")
}
var a : [(a: Int, b: (Void) -> Void)] = []
a.append(a: 2, b: f1)
for(var i = a.count-1; i >= 0; i--){
a[i].b()
}
The error I'm getting is the following: "Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)" just on the call:
a[i].b()
while if I type:
a[i].b
Playground suggest me: "(Function)"
Any idea on how I could do this? How could I execute the function? Thanks
Even though Swift seems to prefer the Unnamed tuples the problem seems to be solved with the new Swift version 1.2 (In my tests that worked only with unnamed tuples)