2011-10-08 3 views
0

J'ai un contrôleur de vue personnalisé affichant les détails de l'élément sélectionné dans le RootViewController dans une application de navigation typique.UITextView génère une erreur exc_bad_access

Le contrôleur de détail dispose de 2 sorties, connectées à l'interface de pointe. Je viens juste de faire une affectation dans ViewDidLoad et de la libérer dans dealloc.

En cours d'exécution de l'application, après avoir appuyé sur le bouton retour dans le contrôleur de détail pour revenir au contrôleur racine, j'obtiens un exc_bad_access de nombreTextView.

Tout le code impliqué et les informations du profil.

EventoDetailViewControllerClass.h

@class YOEvento; 
@interface EventoDetailViewControllerClass : UIViewController 
{ 
    YOEvento *evento; 
    IBOutlet UITextView *nombreTextView; 
    IBOutlet UITextView *entradillaTextView; 
} 
@property (nonatomic, retain) YOEvento *evento; 
@property (nonatomic, retain) IBOutlet UITextView *nombreTextView; 
@property (nonatomic, retain) IBOutlet UITextView *entradillaTextView; 
@end 

EventoDetailViewControllerClass.m

#import "YOEvento.h" 
@implementation EventoDetailViewControllerClass 
@synthesize evento, nombreTextView, entradillaTextView; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view from its nib. 
    self.nombreTextView.text = self.evento.nombre; 
    self.entradillaTextView.text = self.evento.entradilla; 

} 

- (void)dealloc { 
    [nombreTextView dealloc]; 
    [entradillaTextView dealloc]; 
    [evento dealloc]; 

    [super dealloc]; 
} 

L'appel à RootViewController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Create a new detailViewController 
    EventoDetailViewControllerClass *detailViewController = [[EventoDetailViewControllerClass alloc] initWithNibName:@"EventoDetailViewControllerClass" bundle:nil]; 
    // Get the current evento selected 
    YOEvento *auxEvento = [self.eventosList objectAtIndex:indexPath.row]; 
    // Pass the evento to detailViewController 
    detailViewController.evento = auxEvento; 

    // Reset auxEvento Reference 
    auxEvento = nil; 
    // Push detailViewController on top of the stack. 
    [self.navigationController pushViewController:detailViewController animated:YES]; 
    // Release detailViewController 
    [detailViewController release]; 
} 

Profil J'obtiens ce qui suit:


# Category Event Type RefCt Timestamp Address Size Responsible Library Responsible Caller 
0 UITextView Malloc 1 00:23.646.688 0xbe750e0 448 UIKit -[UIRuntimeConnection initWithCoder:] 
1 UITextView Retain 2 00:23.659.360 0xbe750e0 0 UIKit -[UITextView resignFirstResponder] 
2 UITextView Autorelease  00:23.659.367 0xbe750e0 0 UIKit -[UITextView resignFirstResponder] 
3 UITextView Retain 3 00:23.660.912 0xbe750e0 0 UIKit -[UIRuntimeConnection initWithCoder:] 
4 UITextView Retain 4 00:23.660.915 0xbe750e0 0 Foundation -[NSKeyedUnarchiver _replaceObject:withObject:] 
5 UITextView Release 3 00:23.660.919 0xbe750e0 0 UIKit -[UIRuntimeConnection initWithCoder:] 
6 UITextView Retain 4 00:23.660.922 0xbe750e0 0 UIKit -[UIRuntimeConnection initWithCoder:] 
7 UITextView Release 3 00:23.660.964 0xbe750e0 0 UIKit -[UIRuntimeConnection initWithCoder:] 
8 UITextView Autorelease  00:23.661.342 0xbe750e0 0 UIKit -[UIRuntimeConnection initWithCoder:] 
9 UITextView Retain 4 00:23.661.346 0xbe750e0 0 UIKit -[UIRuntimeConnection initWithCoder:] 
10 UITextView Retain 5 00:23.661.720 0xbe750e0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] 
11 UITextView Retain 6 00:23.661.733 0xbe750e0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] 
12 UITextView Release 5 00:23.661.744 0xbe750e0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] 
13 UITextView Retain 6 00:23.661.758 0xbe750e0 0 Foundation -[NSArray(NSArray) initWithCoder:] 
14 UITextView Release 5 00:23.661.780 0xbe750e0 0 UIKit -[UIView initWithCoder:] 
15 UITextView Retain 6 00:23.661.828 0xbe750e0 0 UIKit -[UIView(Internal) _addSubview:positioned:relativeTo:] 
16 UITextView Release 5 00:23.665.628 0xbe750e0 0 UIKit -[UINib instantiateWithOwner:options:] 
17 UITextView Retain 6 00:23.665.897 0xbe750e0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] 
18 UITextView Retain 7 00:23.665.916 0xbe750e0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] 
19 UITextView Release 6 00:23.665.928 0xbe750e0 0 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] 
20 UITextView Retain 7 00:23.665.950 0xbe750e0 0 Foundation -[NSArray(NSArray) initWithCoder:] 
21 UITextView Release 6 00:23.665.977 0xbe750e0 0 UIKit -[UINib instantiateWithOwner:options:] 
22 UITextView Retain 7 00:23.666.102 0xbe750e0 0 Proyecto3 -[EventoDetailViewControllerClass setNombreTextView:] 
23 UITextView Release 6 00:23.666.280 0xbe750e0 0 Foundation -[NSKeyedUnarchiver dealloc] 
24 UITextView Release 5 00:23.666.333 0xbe750e0 0 Foundation -[NSKeyedUnarchiver dealloc] 
25 UITextView Release 4 00:23.666.348 0xbe750e0 0 Foundation -[NSKeyedUnarchiver dealloc] 
26 UITextView Release 3 00:23.666.404 0xbe750e0 0 Foundation -[NSKeyedUnarchiver dealloc] 
27 UITextView Release 2 00:23.666.466 0xbe750e0 0 UIKit -[UIRuntimeConnection dealloc] 
28 UITextView Retain 3 00:23.677.242 0xbe750e0 0 QuartzCore -[CALayer layoutSublayers] 
29 UITextView Release 2 00:23.677.244 0xbe750e0 0 QuartzCore CALayerLayoutIfNeeded 
30 UITextView Retain 3 00:23.703.612 0xbe750e0 0 UIKit -[UIView(Hierarchy) subviews] 
31 UITextView Zombie -1 00:26.613.518 0xbe750e0 0 UIKit -[UIView(Internal) _invalidateSubviewCache] 

Répondre

2

Vous ne devez pas appeler la méthode dealloc pour des objets non super. Remplacez votre dealloc par le suivant:

- (void)dealloc { 
    [nombreTextView release]; 
    [entradillaTextView release]; 
    [evento release]; 

    [super dealloc]; 
} 
+0

Je ne peux pas croire que j'ai manqué celui-là. C'est le code qu'on remplit à la hâte sans regarder l'écran. Et lors de l'examen je regarde juste si l'instance vars là. –