I have a method with a closure as a parameter that defaults to a 'dummy' function if no closure is provided. However, whenever I try omitting the parameter with the default, the compiler throws the error:
Missing argument for parameter 'closureFuncWithDefault' in call
Insert 'parameterClosureFuncWithDefault: <#(object) -> Void#>'
My code is as follows:
func functionWithDefault (object: SCNReferenceNode = SCNReferenceNode(),
closureWithDefault: @escaping (_ object: SCNReferenceNode)->Void = { _ in return }) {
otherClassInstance.loadObject (object, loadedHandler: { [unowned self] loadedObject in DispatchQueue.main.async {
self.otherMethod (loadedObject)
closureWithDefault (virtualObject)
}
})
}
Then from somewhere else:
// some code
var objectThing = SCNReferenceNode (URL: ..... )
//
// code block...
//
functionWithDefault (object: objectThing) // <-- This throws the error.
SCN class and such things are not the relevant things, rather, the proper way to have a closure parameter with a default and being able to use it.