Search code examples
objective-csknodesklabelnode

SKLabelNode.name target for setText


Question

How to target an SKLabelNode by name? to change it's text?

Example;

SKNode *node = [self childNodeWithName:string];
[node setText:value];

How does one achieve this? I cannot do it by targeting it's instance variable as I have multiple under the same name, however, all have different names. I just cannot figure out how to target it with an sknode.

And to try and do it with an SKLabelNode *node =... Then it is incompatible.

Any help is much appreciated, thank you.


Solution

  • Going back through my questions and sorting them out.

    SKNode *node = [self childNodeWithName:string];
    SKLabelNode *label = (SKLabelNode *)node;
    
    label.text = @"dwadw";