2011-01-28 48 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

相關問題