Search code examples
iphonefor-loopcocos2d-iphonexcode4.5cgrect

Cocos2d 2.0 error xcode 5.2


for (CCSprite *body in bodyArray) {
    if (CGRectIntersectsRect(snakeHead.boundingBox, body.boundingBox)) {
        [self unscheduleUpdate];
        [self gameOver];
    }
}

This is my code which worked perfectly on xcode4.2 osx 10.6.8, but when I HAD to upgrade to xcode 4.5 this gives me a warning "Local declaration of 'body' hides instance variable" I have no single clue what this means and I have searched for the problem but haven't found any soution. Does anyone here understand this warning?


Solution

  • You have an instance variable named body in your .h file. You have used the same name on the following line too
    for (CCSprite *body in bodyArray).

    So this warning message means that instance variable body declared in .h file will not used within the scope of your for loop