我有一个下载图像的对象...当完成图像时,会调用一个方法finishLoad来保存这个图像...我在我的UIViewController中有一个这个对象的列表,我想知道有多少调用此方法的次数,当此count = 10时,我将调用另一种方法。我怎么能这样做?
@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];
}
}
答案 0 :(得分:1)
您可以使用静态变量:
static int myCount = 0;
- (void)finishLoad
{
// ...
myCount++;
if (myCount == 10)
// call your method
}