What is CCARRAY_FOREACH in coccos2d?

I see the CCARRAY_FOREACH macro in coccos2d, actually what is it? can we make an alternative instead? Am I using the following code for spriteBatchNode?

CCARRAY_FOREACH([spriteBatch children], sprite) { ................... } 
+6
cocos2d-iphone
source share
2 answers

this is a macro for scrolling every object inside CCArray ... an alternative would be objective-c foreach for (object in array) , which would look like this:

 for (CCSprite *sprite in [spriteBatch children]) { ... } 

this is for NSArray and NSMutableArray, but I think it works fine for CCArray too.

+1
source share

Another answer is actually wrong. CCARRAY_FOREACH not a quick enumeration macro CCARRAY_FOREACH it is a quick enumeration replacement for CCArray s. CCARRAY_FOREACH slightly faster than a fast enumeration on an NS(Mutable)Array (about 10%), so it is better to use it if you use CCArray s.
Check the CCArray.h header to see what a macro is.

+7
source share

All Articles