2011-07-01 36 views
1

我努力弄清楚爲什麼當我釋放合成屬性時,我的應用程序崩潰。我的應用程序啓動,當我點擊一行時,它將我帶到DetailViewController,然後當我返回並再次點擊一行時,該應用程序與EXC_BAD_ACCESS一起崩潰。在改變類別時,在發佈Var後,主/明細應用程序崩潰

DetailViewController.h:

#import <UIKit/UIKit.h> 

@interface DetailViewController : UIViewController { 

    IBOutlet UILabel *clipboardLabel; 

} 

@property (nonatomic, retain) IBOutlet UILabel *clipboardLabel; 

@end 

DetailViewController.m

#import "DetailViewController.h" 

@implementation DetailViewController 

@synthesize clipboardLabel; 

- (void)viewDidLoad 
{  
    // Do any additional setup after loading the view from its nib. 
    clipboardLabel.text = @"Tap an image to copy"; 
    [super viewDidLoad]; 
} 

- (void)dealloc 
{ 
    [clipboardLabel dealloc];  
    [super dealloc]; 
} 

@end 

回答

1

呼叫release而不是dealloc上的dealloc方法你clipboardLabel。

這應該是:

- (void)dealloc 
{ 
    [clipboardLabel release];  
    [super dealloc]; 
} 

的一般規則:一個應該從未另一個對象調用dealloc

+0

我是個白癡。謝謝。 – squarefrog

+0

@Luzal:貪心很多?在一定的時間過後,他無法接受。 – PengOne

+0

@PengOne:那是我不知道的。謝謝:) – scalbatty

0

不要叫dealloc

[clipboardLabel dealloc]; <-- Wrong 

呼叫釋放:

[clipboardLabel release]; <-- Right 
+0

感謝您的迴應。我正在結束一天的時刻:) – squarefrog

相關問題