I have a lazy parameter that I'm attempting to call a helper function in:
class ColumnNode: SCNNode {
lazy var upperColumnNode: SCNNode = {
return buildColumPart()
}()
func buildColumPart() -> SCNNode {
var node = SCNNode()
...
return node
}
}
Unfortunately on line return buildColumPart()
I am getting:
Missing argument for parameter #1 in call
What exactly does this mean and how do I fix it?
You need to use self
to access instance methods in lazy properties:
class ColumnNode: SCNNode {
lazy var upperColumnNode: SCNNode = {
return self.buildColumPart()
}()
func buildColumPart() -> SCNNode {
var node = SCNNode()
...
return node
}
}
Interestingly enough, the reason it's complaining about parameter #1 is that instance methods are actually class methods that take an instance as a parameter and return a closure with the instance captured - instead of self.buildColumPart()
, you could instead call buildColumPart(self)()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With