Search code examples
iphoneobjective-ccocos2d-iphone

Iterating through children of a layer in cocos2d


I am trying to iterate through and remove all children of my layer (HUDLayer). I am trying to accomplish this task with:

    for(id *item in HUDLayer.children_)
    {
        [self removeChild:item cleanup:YES];
    }

But I get an error -> Expression does not have a valid object type

Can someone shed some light on my issue?

Thank you


Solution

  • for(id *item
    

    Whoops. id is an object itself (and a pointer too), no need for the asterisk.

    for(id item in HUDLayer._children)
    

    should be fine.