title: Change NSMenuItem state in MenuController from AppController?
body: <p>My code is split into two main implementations: MenuController.m and AppController.m, each with header files.</p>
  
  <p>I have a couple user preferences, which are stored using NSUserDefaults, and changed via NSMenuItems so that they show check marks when enabled (using <strong>setState: NSOffState</strong>).  There's only one missing bit of my setup- I need the app to <strong>setState</strong> for those menu items on startup if the options are on in the prefs.  However, the only way I know to set something on app launch is to have it in the <strong>awakeFromNib</strong> method, and that's in the AppController and can't access the <strong>NSMenuItem</strong> instantiated in the MenuController.</p>
  
  <p>I am rather new to Objective-C, and have managed to get this far thanks to many helpful tutorials and answers on this site, but right now I'm just stumped.</p>
  
  <p>I've tried using class and object methods to change the settings, but have failed- I need to use the existing instance of the NSMenuItems.  <strong>validateMenuItem</strong> looked promising, but it only enables and disables menus and doesn't setState.</p>
  
  <p>Relevant code (I think):</p>
  
  <p>from MenuController.h:</p>
  
  <pre><code>@interface MenuController : NSMenu {
   IBOutlet NSMenu *optionsMenu;
   IBOutlet NSMenuItem *onTopItem;
   IBOutlet NSMenuItem *liveIconItem;
  }
  
  - (IBAction)menuLiveIconToggle:(id)pid;
  </code></pre>
  
  <p>from MenuController.m: (method to change prefs and setState- works great)</p>
  
  <pre><code>- (IBAction)menuLiveIconToggle:(id)pid; {
   //NSLog(@"Live Icon Toggle");
   NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
   if ([standardUserDefaults boolForKey:@"LiveIcon"] == TRUE){
    [standardUserDefaults setBool:FALSE forKey:@"LiveIcon"];
    [liveIconItem setState: NSOffState];
   } else {
    [standardUserDefaults setBool:TRUE forKey:@"LiveIcon"];
    [liveIconItem setState: NSOnState];
   }
   [standardUserDefaults synchronize];
  }
  </code></pre>
  
  <p>from AppController.m: (does NOT work, but this is the gist of it)</p>
  
  <pre><code>- (void) awakeFromNib{
   // Update menu items
   if ([standardUserDefaults boolForKey:@"LiveIcon"] == TRUE) {
    [liveIconItem setState: NSOnState];
   } else {
    [liveIconItem setState: NSOffState];
   }
  }
  </code></pre>
  
  <p>Thanks for any help!</p>