I'm working on a SpriteKit project and my SKSpriteNode has a simple name:
node.name = @"cat"
However, when I try to do [self childWithName:@"cat"], I do not retrieve my object. Through some research I noticed some people mentioning I should be doing
[self childWithName:@"//cat"]
and that works. I was wondering what having the "//" does?
It doesn't do special things for all
NSStrings, just strings used to search the node tree, for which it recursively searches all ofself's children.From the documentation:
So, for example, let's say you have this node tree:
Without
//,childNodeWithName:would only findchild1orchild2. With//, it would findchild1,child2,grandchild1,grandchild2,grandchild3, orgrandchild4.