得到这个代码在我的控制器(无效)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