"数据格式化程序暂时不可用......"错误

Aks*_*hay 2 iphone memory-management objective-c ipad ios

可能重复:
编程接收信号:"0".数据格式化程序暂时不可用

我在XiB上取200个OBShapedButtons并在那里设置背景图像.之后,我将拍摄特定OBShapedButton的图像,并将图像着色并再次将其设置为OBShapedButton的背景.

-(void)onTick:(NSTimer *)timer {
    //Database
    UIImage *setColor=[[UIImage alloc] init];
    for (int i=0; i<[dataArray count]; i++)
    { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        currentLevelMaleValue =[[[dataArray objectAtIndex:i] objectForKey:@"CurrentLevelMaleColor"] doubleValue];
        printf("Current val is %f",currentLevelMaleValue);
        for (OBShapedButton *obshapedCountryButtons in scrollBaseView.subviews) 
        {
            if (obshapedCountryButtons.tag==i+1) 
            {
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapButton:)];
                tap.numberOfTouchesRequired=1;
                tap.numberOfTapsRequired=1;
                [obshapedCountryButtons addGestureRecognizer:tap];
                [obshapedCountryButtons addTarget:self action:@selector(buttonTagTrap:) forControlEvents:UIControlEventTouchDown];
                //[obshapedCountryButtons addTarget:self action:@selector(tapButton:) forControlEvents:UIControlStateHighlighted];
                setColor=[obshapedCountryButtons imageForState:UIControlStateNormal];
                countryCode =[self getCountryColorCurrentLevel:currentLevelMaleValue];
                setColor =[setColor imageTintedWithColor:countryCode];
                [obshapedCountryButtons setImage:setColor forState:UIControlStateNormal];[pool release];
                //    [setColor release];
                //    [obshapedCountryButtons release];
                //    [tap release]; 
                //         
            }

            //  }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,我收到此错误[循环执行约40次后] -

程序接收信号:"0".数据格式化程序暂时不可用,将在"继续"后重试.(加载共享库时出现未知错误"/Developer/usr/lib/libXcodeDebuggerSupport.dylib

收到此警告 -

收到内存警告

然后该应用程序将被终止.

注意 :

没有对象分配.

请帮我解决一些想法.我该怎么办呢?

Ila*_*ian 5

UIImage *setColor=[[UIImage alloc] init];
Run Code Online (Sandbox Code Playgroud)

是一个内存泄漏,因为你没有释放它.实际上,分配不是必需的,因为您要为其分配一些其他值.同样tap也没有发布,因为您已经注释了该代码.

对此的建议.尝试将这段代码放入NSAutoreleasePool.

编辑:

-(void)onTick:(NSTimer *)timer {
    //Database
    UIImage *setColor;// =[[UIImage alloc] init];
    for (int i=0; i<[dataArray count]; i++)
    { 
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        currentLevelMaleValue =[[[dataArray objectAtIndex:i] objectForKey:@"CurrentLevelMaleColor"] doubleValue];
        printf("Current val is %f",currentLevelMaleValue);
        for (OBShapedButton *obshapedCountryButtons in scrollBaseView.subviews) 
        {
            NSAutoreleasePool * pool1 = [[NSAutoreleasePool alloc] init];
            if (obshapedCountryButtons.tag==i+1) 
            {
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapButton:)];
                tap.numberOfTouchesRequired=1;
                tap.numberOfTapsRequired=1;
                [obshapedCountryButtons addGestureRecognizer:tap];
                [obshapedCountryButtons addTarget:self action:@selector(buttonTagTrap:) forControlEvents:UIControlEventTouchDown];
                //[obshapedCountryButtons addTarget:self action:@selector(tapButton:) forControlEvents:UIControlStateHighlighted];
                setColor=[obshapedCountryButtons imageForState:UIControlStateNormal];
                countryCode =[self getCountryColorCurrentLevel:currentLevelMaleValue];
                setColor =[setColor imageTintedWithColor:countryCode];
                [obshapedCountryButtons setImage:setColor forState:UIControlStateNormal];[pool release];
                //    [setColor release];
                //    [obshapedCountryButtons release];
                [tap release]; 

            }
            [pool1 drain];
        }
        [pool drain];
    }
}
Run Code Online (Sandbox Code Playgroud)