Juan Munhoes Junior
Juan Munhoes Junior

Reputation: 895

Count fired method

I have an object that download an image...and when finish the image, a method finishLoad is called to save this image...and i have a list of this object in my UIViewController, i want to know how many times this method is called, and when this count = 10, i ll call another method. How could i do it?

@implementation DownloaderImage
{
    - (void)finishLoad {
//:: hide default image ::
[self setImage:nil];

//:: fade in in loaded picture ::
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0, 0);
[finalImage setTransform:myTransform];
finalImage.alpha = 1.0;

UIImage *scaledImage = [finalImage.image scaleToSize:CGSizeMake(320.0f, 345.0f)];
finalImage.image = scaledImage;

//:: fade out background picture ::
[backgroundImage setTransform:myTransform];
backgroundImage.alpha = 0.0;

[UIView commitAnimations];
 }
}

Upvotes: 0

Views: 57

Answers (1)

iSofTom
iSofTom

Reputation: 1718

You can use a static variable :

static int myCount = 0;

- (void)finishLoad
{
    // ...
    myCount++;
    if (myCount == 10)
        // call your method
}

Upvotes: 1

Related Questions