Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 计数激发法_Ios - Fatal编程技术网

Ios 计数激发法

Ios 计数激发法,ios,Ios,我有一个下载图像的对象…当完成图像时,调用finishLoad方法来保存此图像…我的UIViewController中有一个此对象的列表,我想知道调用此方法的次数,当此计数=10时,我将调用另一个方法。我怎么做呢 @implementation DownloaderImage { - (void)finishLoad { //:: hide default image :: [self setImage:nil]; //:: fade in in loaded picture :: [

我有一个下载图像的对象…当完成图像时,调用finishLoad方法来保存此图像…我的UIViewController中有一个此对象的列表,我想知道调用此方法的次数,当此计数=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];
 }
}

您可以使用静态变量:

static int myCount = 0;

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

但是有很多这样的对象,我会考虑10考虑列表中的所有对象,而不是个人认为我是一个委托,当这个方法被激发时,我想用我的UIVIEW控制器中的静态int来计算静态变量的用途,否则使用一个公共的实例变量。