应用程序仅在iPad模拟器上崩溃

时间:2013-08-02 18:49:00

标签: ipad ios-simulator exc-bad-access

我正在开发适用于iPad的应用程序,它在两者(iPad和iPad模拟器)中运行得很好,然后我需要添加另一个线程来并行运行两个东西然后在我运行应用程序时,随机崩溃(有时运行正常,有时不运行)这是输出:

libobjc.A.dylib`objc_msgSend:
0x1b4a08c:  movl   8(%esp), %ecx
0x1b4a090:  movl   4(%esp), %eax
0x1b4a094:  testl  %eax, %eax
0x1b4a096:  je     0x1b4a0e8                 ; objc_msgSend + 92
0x1b4a098:  movl   (%eax), %edx
0x1b4a09a:  pushl  %edi
0x1b4a09b:  movl   8(%edx), %edi <---- Thread 15: EXC_BAD_ACCESS (code = 1, address = 0xe0000008)
所有输出部分的

只显示此

(lldb) 

当我在iPad(不是模拟器)上运行相同的应用程序时,一切都运行得很好,不知道为什么会发生任何帮助我会很感激


编辑:抱歉,这是代码:

这就是它的作用: 1.在主线程中我发送应用程序在画布上打印存储在对象中的签名(使用“for”打印每个点并通过这形成整个签名 2.在第二个线程(已创建)中我想在签名形成时在标签上(实时)打印签名生物特征值

- (IBAction)printSignature{


        //extracts the signature from a file and stores in an object
        NSData  *datos  = [self desSerializarFirma:[self traerFirmadeBD]];
        DatosBiometricosFirma  *firmaCompleta  = [NSKeyedUnarchiver unarchiveObjectWithData:datos];

        //here starts the cycle for printing each point of the signature
        for (int i = 0; i < [firmaCompleta.location count]; i++) {

            SmoothStroke *currentStroke = [canvasView getStrokeForTouchHash:[[firmaCompleta.touchHash objectAtIndex:i] intValue]];

            //this function prints the point on the canvas providing location, width, color...
            [canvasView addLineToAndRenderStroke:currentStroke
                                         toPoint:CGPointFromString([firmaCompleta.location objectAtIndex:i])
                                         toWidth:[canvasView widthForPressure:[[firmaCompleta.pressure objectAtIndex:i] intValue]]
                                         toColor:[canvasView colorForPressure:[[firmaCompleta.pressure objectAtIndex:i] intValue]]];



            /*----------------------------- BIOMETRIC CALCULATIONS    -----------------------------*/
            /*-----------------------------------------------------------------------------------*/

            //1. SPEED  ---------------------------------------------------------------------*/

            //start running the line of time
            if (tiempoInicioTrazo == nil)  tiempoInicioTrazo = [NSDate date];

            //this applies when the first point of the line is drawn
            if (puntoAnteriorTrazo.x == 0 && puntoAnteriorTrazo.y == 0)
                velocidadTrazo = [self calculaVelocidadTrazodelPuntoA:CGPointFromString([firmaCompleta.location objectAtIndex:i])
                                                             alPuntoB:CGPointFromString([firmaCompleta.location objectAtIndex:i])
                                                        momentoInicio:tiempoInicioTrazo];

            // if the line has already begun
            if (puntoAnteriorTrazo.x != 0 && puntoAnteriorTrazo.y != 0)
                velocidadTrazo = [self calculaVelocidadTrazodelPuntoA:puntoAnteriorTrazo
                                                             alPuntoB:CGPointFromString([firmaCompleta.location objectAtIndex:i])
                                                        momentoInicio:tiempoInicioTrazo];

            puntoAnteriorTrazo = CGPointFromString([firmaCompleta.location objectAtIndex:i]);
            //1. END SPEED  ------------------------------------------------------------------*/


              //Setting things ready for the other thread------                 


             //it creates an array for storing all biometric results
             if (!valoresFirma)  valoresFirma = [[NSMutableArray alloc]init];
            [valoresFirma removeAllObjects];
            NSMutableString *presionString   = [[NSMutableString alloc]initWithString:@""];
            NSMutableString *velocidadString = [[NSMutableString alloc]initWithString:@""];
            NSMutableString *ubicacionString = [[NSMutableString alloc]initWithString:@""];

            if ([[firmaCompleta.pressure objectAtIndex:i] length] > 0)
            [presionString appendString:[NSString stringWithFormat: @"%f", [canvasView widthForPressure:[[firmaCompleta.pressure objectAtIndex:i] intValue]]]];

            if (velocidadTrazo > 0)
                [velocidadString appendString:[NSString stringWithFormat:@"%f",velocidadTrazo]];

            if ([[firmaCompleta.location objectAtIndex:i] length] > 0)
                [ubicacionString appendString:[firmaCompleta.location objectAtIndex:i]];


              [valoresFirma addObject:presionString];
              [valoresFirma addObject:velocidadString];
              [valoresFirma addObject:ubicacionString];

            //Here I trigger the second thread passing all results of the stroke stored in the array (pressure, speed and location for being printed on real time)
            [NSThread detachNewThreadSelector:@selector(imprimeValoresFirmaEnTabla:) toTarget:self withObject:valoresFirma];

        }
}

并且线程触发的第二个块只会在我的标签上打印出这样的结果

-(void)imprimeValoresFirmaEnTabla:(NSMutableArray *)valores{

    if ([valoresFirma count] >= 3) {
        if ([[valores objectAtIndex:0] length] > 0) self.pressureStrokeLabel.text = [valores objectAtIndex:0];
        if ([[valores objectAtIndex:1] length] > 0) self.speedStrokeLabel.text    = [valores objectAtIndex:1];
        if ([[valores objectAtIndex:2] length] > 0) self.locationStrokeLabel.text = [valores objectAtIndex:2];
    }
}
我做错了什么!!!仍然不知道是什么让我的代码崩溃

0 个答案:

没有答案