得到這個代碼在我的控制器(無效)viewDidLoad方法iPhone應用程序崩潰時,我使用一個NSMutableDictionary
self.purchasesPerClassification = [NSMutableDictionary
dictionaryWithObjects:[NSArray arrayWithObjects:@"Moo",nil]
forKeys:[NSArray arrayWithObjects:@"MooKey",nil]
];
據我可以下架這些都是因爲我沒有使用過的alloc初始化, 自動釋放在我的dealloc我有
[self.purchasesPerClassification release];
這是用的UITableViewController控制器的一部分,該控制器創建一個從主容器裝入添加到主contollers navigationController這似乎讓我的應用程序崩潰的模擬器WH恩我沒有它在正常工作的指針,爲什麼這個代碼崩潰
繼承人的.H
@interface FirstAiderInsurancePurchasesViewController : UITableViewController {
NSArray * availableClassifications;
NSMutableDictionary * purchasesPerClassification;
}
@property(nonatomic, retain) NSArray * availableClassifications;
@property(nonatomic, retain) NSMutableDictionary * purchasesPerClassification;
@end
和繼承人的.M部分
@implementation FirstAiderInsurancePurchasesViewController
@synthesize availableClassifications;
@synthesize purchasesPerClassification;
- (void)viewDidLoad {
[super viewDidLoad];
self.availableClassifications = [NSMutableArray arrayWithObjects:@"Completed",@"Recover's",nil];
self.purchasesPerClassification = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Object",nil]
forKeys:[NSArray arrayWithObjects:@"ObjectKey",nil]];
}
- (void)dealloc {
[super dealloc];
self.availableClassifications = nil;
self.purchasesPerClassification = nil;
}
我試着既
[purchasesPerClassification release];
以及其崩潰,當我回去的根控制器
好吧,我的壞處應該已經發布了整個源代碼,所以這裏是.h – ssmithstone 2010-11-18 18:43:31
只是一個快速的評論。你會想要[super dealloc]最後。可能不會幫助這個問題,但可能會導致後來的泄漏。 – DerekH 2010-11-18 19:29:09
似乎已經修復了它,我已經發布了修復它的viewDidUnload方法,但在其他版本工作後調用了[super dealloc] – ssmithstone 2010-11-18 21:13:21