cocos2d : CCsprite setVisible method not working
===

In an cocos 2d game i user 3 heart sprites to update lives of hero.If hero lost one life..one heart should be hided.



I use below code but its not working properly.please help me.
  

      - (void)updateLives {
                int i = _lives;
                [self livess:(int)i];
            }


 <br>.

   


    - (void)livess:(int)string { 

        CGSize winSize = [CCDirector sharedDirector].winSize;
        heart1=[CCSprite spriteWithFile:@"heart.png"];
        heart2=[CCSprite spriteWithFile:@"heart.png"];
        heart3=[CCSprite spriteWithFile:@"heart.png"];
        [heart1 setPosition:ccp(winSize.width/2*1.3, winSize.height * 0.9)];
        [self addChild:heart1 z:0];
        [heart2 setPosition:ccp(winSize.width/2*1.1, winSize.height * 0.9)];
        [self addChild:heart2 z:0];
        [heart3 setPosition:ccp(winSize.width/2*0.9, winSize.height * 0.9)];
        [self addChild:heart3 z:0];
        
      
        if (string==3) {
             
            NSLog(@"%d",string);
        }
        else if (string==2)
        {
            NSLog(@"%d",string);
            
            [heart3 setVisible:NO];
            
        }else if (string==1)
        {
            
            NSLog(@"%d",string);
            
            [heart3 setVisible:NO];
            [heart2 setVisible:NO];
        }
        else
        {
            
        }
         
    }




note:in above code..nslog is printing correct values ..for example 1,2
