저는 Objective-C와 Cocoa에 아직 익숙하지 않지만 배우려고합니다. 간단한 ToDo 관리자를 만들고 있지만 EXC_BAD_ACCESS 크래시가 계속 발생하며 이유가 확실하지 않습니다. 충돌이 main.m 파일에서 발생합니다. "return NSApplicationMain (argc, (const char **) argv);" 그래서 정말 디버그하기가 어렵습니다.Objective-C & EXC_BAD_ACCESS
내 응용 프로그램 대리인의 실제 구현 파일은 다음과 같습니다. 어떻게됩니까
#import "ToDoAppDelegate.h"
#import "Task.h"
@implementation ToDoAppDelegate
@synthesize textTaskName;
@synthesize taskDate;
@synthesize window;
@synthesize newTaskWindow;
@synthesize tableView;
@synthesize arrayController;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
taskArray = [[NSMutableArray alloc] init];
[taskArray retain];
}
- (IBAction)addTaskClick:(id)sender
{
[NSApp beginSheet:newTaskWindow modalForWindow:window modalDelegate:self didEndSelector:NULL contextInfo:NULL];
[taskDate setDateValue:[NSDate date]];
}
- (IBAction)btnSaveClick:(id)sender
{
Task *newTask = [[Task alloc] init];
[newTask setTaskName:[textTaskName stringValue]];
[newTask setTaskDueDate:[taskDate dateValue]];
[arrayController addObject:newTask];
[newTask release];
[textTaskName setStringValue:@""];
[NSApp endSheet:newTaskWindow];
[newTaskWindow orderOut:self];
}
- (IBAction)btnCancelClick:(id)sender
{
[NSApp endSheet:newTaskWindow];
[newTaskWindow orderOut:self];
}
@end
는 btnSaveClick의 메서드를 호출 할 때, 나는이 방법은 실행이 완료된 직후 EXC_BAD_ACCESS 충돌을 얻을 수있다.
(gdb) bt
#0 0x00007fff851d212d in objc_msgSend()
#1 0x00007fff80f9d1e6 in _CFAutoreleasePoolPop()
#2 0x00007fff809a0fe0 in -[NSAutoreleasePool drain]()
#3 0x00007fff8780451f in -[NSApplication run]()
#4 0x00007fff877fd1a8 in NSApplicationMain()
#5 0x0000000100001a82 in main (argc=1, argv=0x7fff5fbff638) at /Users/mattwise1985/Documents/Development/xCode Projects/ToDo/ToDo/main.m:13
이 사람이 내가 잘못이 무엇인지 확인하기 위해 다운로드하고자하는 경우 난 상관 없어 그냥 테스트 프로젝트이기 때문에 : 여기
은 충돌에 대한 역 추적입니다. 여기에서 다운로드 할 수 있습니다. http://www.narfsoft.com/downloads/ToDo.zip
충돌이 발생하면 GDB의 백 트레이스를 보여주십시오. –
메인 포스트에 백 트레이스를 추가했습니다. – QuantumPhysGuy