Contents

replaceChildNode(_:with:)

Removes a child from the node’s array of children and inserts another node in its place.

Declaration

func replaceChildNode(_ oldChild: SCNNode, with newChild: SCNNode)

Parameters

  • oldChild:

    The existing child node to be replaced.

  • newChild:

    The node with which to replace the child node.

Discussion

If both the oldChild and newChild nodes are children of the node, calling this method swaps their positions in the array. Note that removing a node from the node hierarchy may result in it being deallocated.

Calling this method results in undefined behavior if the oldChild parameter doesn’t refer to a child of this node.

See Also

Managing the Node Hierarchy