• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting a reference to an NSMenuItem from another nib?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting a reference to an NSMenuItem from another nib?


  • Subject: Re: Getting a reference to an NSMenuItem from another nib?
  • From: Bill Bumgarner <email@hidden>
  • Date: Tue, 14 Jun 2005 10:39:27 -0700

On Jun 14, 2005, at 10:17 AM, Andy Lee wrote:
I personally think long switch statements are as ugly as long cascading if statements. Either way, I don't mind if they're isolated to a couple of well-known usages like -validateMenuItem:. I also think tags are a little more trouble to maintain than selectors, but I've used both.

Agreed. -validateMenuItem: is one of the few sort of "choke points" in the responder chain. That is, a spot where a single method is handling many different actions. At least, one of the very few where the developer is expected to override the default beahavior.


Given that menu item validation is often automatic simply because of the presence/absence of a particular selector in the responder chain, if you end up with a really long chain of case statements or if/else statements in your validateMenuItem:, it may likely be because your responder chain isn't appropriately factored or could be refactored to subdivide the functionality more cleanly.

You can also bind a menu item's "enabled" value to some particular attribute of some object somewhere. Now, menu items appear in the main NIB file and your document will typically have the controllers bound through to the object model. But it isn't hard to add a controller in the main menu that effectively provides a "gateway" through to the current document's model.

This isn't completely elegant because of the location of the main menu in the "other" nib, but it does work....

b.bum
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Getting a reference to an NSMenuItem from another nib?
      • From: Sherm Pendley <email@hidden>
References: 
 >Re: Getting a reference to an NSMenuItem from another nib? (From: "Theodore H. Smith" <email@hidden>)
 >Re: Getting a reference to an NSMenuItem from another nib? (From: Sherm Pendley <email@hidden>)
 >Re: Getting a reference to an NSMenuItem from another nib? (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: Getting a reference to an NSMenuItem from another nib?
  • Next by Date: Re: NSSliderCell does not use drawBarInside:flipped:?
  • Previous by thread: Re: Getting a reference to an NSMenuItem from another nib?
  • Next by thread: Re: Getting a reference to an NSMenuItem from another nib?
  • Index(es):
    • Date
    • Thread