title: Can't make undo & redo to work in cocoa core data app
body: <p>I have problem to implement undo and redo in my core data cocoa application. This is second question that I am asking on same topic, (<a href="https://stackoverflow.com/questions/35248999/undo-and-redo-in-core-data-cocoa-application-is-this-normal-behaviour">you can read my first question here</a>) and even that I get solid advice on my first question, I still can't make undo and redo to work. </p>
  
  <p>Anyway...here is my current code:</p>
  
  <p>Here is the relevant code from MainWindowController.h file:</p>
  
  <pre><code>#import &lt;Cocoa/Cocoa.h&gt;
  #import "AppDelegate.h"
  
  @property (nonatomic,strong) NSManagedObjectContext *mObjContext;
  @property AppDelegate *appDelegate;
  </code></pre>
  
  <p>Here is the code from the MainWindowController.m file:</p>
  
  <pre><code>#import "MainWindowController.h"
  @interface MainWindowController () &lt;NSWindowDelegate&gt;
  
  @end
  
  @implementation MainWindowController
  
  - (void)windowDidLoad {
      self.appDelegate = (AppDelegate*)[[NSApplication sharedApplication] delegate];
      self.mObjContext = self.appDelegate.managedObjectContext;
      [[self window]setDelegate:self];
      [self windowWillReturnUndoManager:self.window];
  }
  
  - (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window
  {
      return [[self document] undoManager];
  }
  
  @end
  </code></pre>
  
  <p>My window has the following Outlets in connection inspector: delegate: File's owner</p>
  
  <p>Menu: MainMenu</p>
  
  <p>Whenever I make changes in the records in my nstableviews, changes are recorded but undo and redo menu items remain gray. I placed break point in windowWillReturnUndoManager, but I can't see any undoManager returned there...Can anyone tell me what I am doing wrong?</p>