title: Objective-C & EXC_BAD_ACCESS
body: <p>I'm still really new to Objective-C and Cocoa but I am trying to learn. I am creating a simple ToDo manager but I keep getting a EXC_BAD_ACCESS crash and I'm not sure why. The crash is happening in my main.m file here "return NSApplicationMain(argc, (const char **)argv);" so it is really hard to debug.</p>
  
  <p>Here is my actual implementation file for my app delegate.</p>
  
  <pre><code>#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
  </code></pre>
  
  <p>What happens is when the btnSaveClick method is called, I get the EXC_BAD_ACCESS crash right after the method finishes executing.</p>
  
  <p>Here is the backtrace for the crash:</p>
  
  <pre><code>(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
  </code></pre>
  
  <p>Since this is just a test project I don't mind if someone wants to download it to check out what I have wrong. It can be downloaded from here: <a href="http://www.narfsoft.com/downloads/ToDo.zip" rel="nofollow">http://www.narfsoft.com/downloads/ToDo.zip</a></p>