Lors de l'analyse de notre projet, Xcode est venu avec une notification de fuite de posibe à un UIBarButtonItem personnalisé. J'ai corrigé la fuite, mais lors du chargement de la vue pour la deuxième fois, [super dealloc] donne une erreur EXC_BAD_ACCESS.super dealloc erreur EXC_BAD_ACCESS
Retrait de la autorelease du UIBarButtonItem (afin de retourner l'avertissement):
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:toolbar] autorelease];
donne aucun problème tout en rechargeant l'écran.
personnalisés UIBarButtonItem et le code dealloc:
- (void)viewDidLoad
{
[super viewDidLoad];
// create a toolbar to have the buttons at the right side of the navigationBar
UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 150, 44.01)];
toolbar.tintColor = [UIColor clearColor];
[toolbar setTranslucent:YES];
// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:4];
// Create a comments button
propertiesButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(properties)];
[buttons addObject:propertiesButton];
[propertiesButton release];
// Create a comments button
commentaryButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(comments)];
[buttons addObject:commentaryButton];
[commentaryButton release];
// create a versions button
versionsButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(versions)];
[buttons addObject:versionsButton];
[versionsButton release];
// create a save button
downloadButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:nil action:@selector(download)];
[buttons addObject:downloadButton];
[downloadButton release];
// stick the buttons in the toolbar
[toolbar setItems:buttons animated:NO];
[buttons release];
// and put the toolbar in the nav bar
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:toolbar] autorelease];
[toolbar release];
}
- (void)dealloc
{
[popOverController release];
[propertiesButton release];
[downloadButton release];
[versionsButton release];
[commentaryButton release];
[webView release];
[super dealloc];
}
Avec NSZombieEnabled je reçois
'2011-08-01 10:30:36.571 ProjectName[100:707] *** -[UIBarButtonItem release]: message sent to deallocated instance 0x1fb330'
Nous ne savons pas comment résoudre le problème.
Merci d'avance.
Merci beaucoup! C'est une routine que lorsque je crée une propriété que je les ajoute à la méthode dealloc. Mais quand je le passe à travers un autre objet je les libère aussi. Encore bizarre que xcode me dise que le problème est au [super dealloc]. Merci encore1 – Justin
Bienvenue! Juzzz! – EmptyStack