Callback function syntax in Swift

后端 未结 5 940
南旧
南旧 2020-12-08 10:12

I am attempting pass a function to another function and then have the passed function executed passing to it a variable.

Here is my code:

func showSt         


        
5条回答
  •  不思量自难忘°
    2020-12-08 10:42

    You've declared callback to take no arguments, and then you're trying to pass it an argument.

    You specified type (()->(String))?, which is an optional function that takes no arguments and returns a String.

    Perhaps you mean to specify ((String)->())?, which is an optional function that takes a String and returns nothing.

提交回复
热议问题