I have a function which takes two parameters, the last parameter is a callback closure:
func myAsycTask(name: String, callback: @escaping ()->Void) {
myQueue.async{
self.doTask(name)
callback()
}
}
func doTask(name: String) {...}
I would like to make the 2nd callback closure parameter optional. I tried to re-define the function above to:
func myAsycTask(name: String, callback: @escaping ()->Void? = nil) {
myQueue.async{
self.doTask(name)
callback()
}
}
I get a compiler error:
Nil default argument value of cannot be converted to type '
() ->
'
How can I achieve what I need then?