Instance Method

replaceChildNode:with:

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

Declaration

- (void)replaceChildNode:(SCNNode *)oldChild with:(SCNNode *)newChild;

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

parentNode

The node’s parent in the scene graph hierarchy.

childNodes

An array of the node’s children in the scene graph hierarchy.

- addChildNode:

Adds a node to the node’s array of children.

- insertChildNode:atIndex:

Adds a node to the node’s array of children at a specified index.

- removeFromParentNode

Removes the node from its parent’s array of child nodes.