ios - What does @"//" do in childWithName and when to use it -
i'm working on spritekit project , skspritenode has simple name:
node.name = @"cat"
however, when try [self childwithname:@"cat"]
, not retrieve object. through research noticed people mentioning should doing
[self childwithname:@"//cat"]
and works. wondering having "//" does?
it doesn't special things nsstring
s, strings used search node tree, recursively searches of self
's children.
from documentation:
when placed @ start of search string, [
//
] specifies search should begin @ root node , performed recursively across entire node tree. not legal anywhere else in search string.
so, example, let's have node tree:
scene / \ / \ child1 child2 / \ / \ / \ / \ grandchild1 grandchild2 grandchild3 grandchild4
without //
, childnodewithname:
find child1
or child2
. //
, find child1
, child2
, grandchild1
, grandchild2
, grandchild3
, or grandchild4
.
Comments
Post a Comment