2011-01-28 52 views
0

我有记忆问题(是)我与一个自定义的UIView下面的方法新的iOS):释放实例| “Malloc_history无法检查进程XYZ,因为进程不存在。”

头文件

....  
@property (nonatomic, retain) NSString * pressureTextLabel; 
.... 

实现绘制一个圆,一个标签与关联至压力触摸。每个手指触摸创建该视图的对象:

- (void)drawRect:(CGRect)theRect{ 
    CGRect rect = self.bounds; 
    CGRect ringRect = CGRectInset(rect, 100, 100); 

    // Outer ring. 
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:ringRect]; 
    ringRect = CGRectInset(rect, 60, 60); 
    [path appendPath:[UIBezierPath bezierPathWithOvalInRect:ringRect]]; 
    path.usesEvenOddFillRule = YES; 
    [self.color set]; 
    [path fill]; 

    //text label 
    rect = CGRectMake(100, 20, 100, 100); 

    //This one seems to be the troublemaker 
    [pressureTextLabel drawInRect:rect withFont:[UIFont systemFontOfSize:14.0]]; 

} 

所有只要这以下的方法不被控制器调用以更新此特定触摸感测的压力工作正常。

-(void) setTouchPressureTo: (float) pressure{ 

    pressureTextLabel = [NSString stringWithFormat:@"%f", pressure]; 
    [self setNeedsDisplay]; 

} 

我得到以下错误:

*** -[CFString drawInRect:withFont:]: message sent to deallocated instance 0x16e8c0 

这让我探讨调试控制台的记忆痕迹,一旦应用程序崩溃:shell malloc_history <PID> 0x17dfb0。结果控制台返回:

malloc_history cannot examine process 5838 because the process does not存在。

所以这里的问题是:

  1. 有人能看到明显的保留, 释放问题就在这里?
  2. 我怎样才能获得malloc_history <PID> <Address> 的工作?

谢谢你的时间,重定向和答案!

基督教

+0

如果您在调试器中运行该应用程序,该进程将在发生崩溃后继续运行,并且您可以在其上运行malloc_history。 – 2011-01-28 01:13:05

回答

2

问题是你要指定一个自动释放的对象(你[NSString stringWithFormat...])到伊娃(pressureTextLabel)。你应该使用财产访问,而不是在self.pressureLabel = ...

+0

谢谢凯文!通过使用它自己的作品,但我不明白为什么我的代码导致问题或为什么你解决它。 – chriz 2011-01-28 02:39:26

相关问题