我开发一个应用程序在iOS的如何解决NZombie iOS中
这个应用程序将捕获的签名,也重绘他们从数据库中回...
的问题出现了,当我添加的线程,用于在签名时在标签上实时打印生物特征数据,随机它会崩溃,我的意思是它有时会使签名完整,有时只是签名的3/4,甚至不是它的一半。 ...
使用了一种名为仪器工具试图检测NSZombies,这是我得到了什么?
,并在寻找的代码,这是我发现的代码部分.. 。
这是它崩溃一段代码:
-(void)imprimeValoresFirmaEnTabla:(NSMutableArray *)valores{
if ([valores count] == 3) {
if ([valores objectAtIndex:0] != nil) self.pressureStrokeLabel.text = [valores objectAtIndex:0];
if ([valores objectAtIndex:1] != nil) self.speedStrokeLabel.text = [valores objectAtIndex:1];
if ([valores objectAtIndex:2] != nil) self.locationStrokeLabel.text = [valores objectAtIndex:2];
}
}
它说 - [NSConcreteMutableAtributedString lenght]是负责的僵尸
,这是我的代码:
- (IBAction)drawSignature{
[self clear]; // clear the canvas
NSData *datos = [self desSerializarFirma:[self traerFirmadeBD]]; //unpack the registered signature and store it on the NSData object
if (datos.length <= 1) // if there's no data stored on database
[[[UIAlertView alloc]initWithTitle:@"Notification" message:@"For showing your signature, it is required to register it first, draw your signature on the canvas and tap the Save button" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
if (datos.length > 1) { // if is data stored on database
//store the signature on the object
self.firmaCompleta = [NSKeyedUnarchiver unarchiveObjectWithData:datos];
//this loop draws each point on the canvas
for (int i = 0; i < [self.firmaCompleta.location count]; i++) {
SmoothStroke *currentStroke = [canvasView getStrokeForTouchHash:[[self.firmaCompleta.touchHash objectAtIndex:i] intValue]];
//this draws each point using the biometric info
[canvasView addLineToAndRenderStroke:currentStroke
toPoint:CGPointFromString([self.firmaCompleta.location objectAtIndex:i])
toWidth:[canvasView widthForPressure:[[self.firmaCompleta.pressure objectAtIndex:i] intValue]]
toColor:[canvasView colorForPressure:[[self.firmaCompleta.pressure objectAtIndex:i] intValue]]];
//this stores the biometric data in an array for sending to background thread
if (!valoresFirma) valoresFirma = [[NSMutableArray alloc]init];
[valoresFirma removeAllObjects];
[valoresFirma addObject:[NSString stringWithFormat: @"%f", [canvasView widthForPressure:[[self.firmaCompleta.pressure objectAtIndex:i] intValue]]]];
[valoresFirma addObject:[NSString stringWithFormat:@"%f",velocidadTrazo]];
[valoresFirma addObject:[self.firmaCompleta.location objectAtIndex:i]];
//this triggers the tread for printing the values on labels (real time)
[NSThread detachNewThreadSelector:@selector(imprimeValoresFirmaEnTabla:) toTarget:self withObject:valoresFirma];
}
}
}
和线程调用的代码:
-(void)imprimeValoresFirmaEnTabla:(NSMutableArray *)valores{
if ([valores count] == 3) {
if ([valores objectAtIndex:0] != nil) self.pressureStrokeLabel.text = [valores objectAtIndex:0];
if ([valores objectAtIndex:1] != nil) self.speedStrokeLabel.text = [valores objectAtIndex:1];
if ([valores objectAtIndex:2] != nil) self.locationStrokeLabel.text = [valores objectAtIndex:2];
}
}
感谢提前为您的支持
串在你VALORES阵列已经释放。可能通过另一个线程。 –
如何阻止释放我的valores数组的线程?因为我从其他一些新线程使用它们? –