I have a SpriteKit game where I check if my sknodes have a parent node during the SKScene's update method (by checking if their parent property is nil). If they don't have a parent node, then I know to add them to the SKScene.
I'm worried that if the addChild method is done asynchronously, then the SKScene could begin the addChild method on one particular update frame, but it may not be done with the method by the next update frame. So when it checks the same node's parent property on the next update frame it will still be nil, and thus the SKScene will try to add the same node again.
If this happens, the program could fail because adding the same node twice to the SKScene causes an error.
Ofcourse if addChild is done synchronously then I don't have to worry about this ever happening.
So does anyone know if addChild is done synchronously or asynchronously? Or am I just thinking too far into this and it's not something to worry about?
no the method is synchronous the only 'asynchronous seeming' thing about it, would be the drawing. as the drawing only happens 'between runloop iterations' the visible effect of addChild can be seen as 'delayed'