0
일반적인 탐색 응용 프로그램의 RootViewController에서 선택한 항목의 세부 정보를 표시하는 사용자 지정보기 컨트롤러가 있습니다.UITextView가 exc_bad_access 오류를 생성합니다.
세부 컨트롤러에는 nib 인터페이스와 연결된 2 개의 콘센트가 있습니다. 방금 ViewDidLoad에서 할당을 만들고 dealloc에서 릴리스했습니다.
앱을 실행하면 세부 컨트롤러에서 뒤로 버튼을 눌러 루트 컨트롤러로 돌아간 후 nombreTextView에서 exc_bad_access를 얻습니다.
이것은 모두 관련 코드이며 프로필의 정보입니다.
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];
}
프로필에서
- (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];
}
나는 다음을 얻을 RootViewController의 전화 :
# 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]
나는 그 중 하나를 놓쳤다는 것을 믿을 수 없습니다. 이 코드는 화면을 보지 않고 서두를 채 웁니다. 그리고 리뷰 할 때 인스턴스가 어디에 있는지 살펴 봅니다. –