• 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: Sherm Pendley <email@hidden>
  • Date: Tue, 14 Jun 2005 13:56:46 -0400

On Jun 14, 2005, at 1:17 PM, Andy Lee wrote:

On Jun 14, 2005, at 12:47 PM, Sherm Pendley wrote:

If-tables are only necessary if you're comparing strings. If you're comparing integers - such as tags, for instance - you'd use a switch:

-(BOOL) validateMenuItem:(NSMenuItem*)anItem {
    switch([anItem tag]) {
        case 0:
            /* ... */
        case 1:
            /* ... */
        default:
            return YES;
    }
}


I personally think long switch statements are as ugly as long cascading if statements.

I have no opinion one way or the other - the idea is just about the same either way. The compiler will be able to generate faster code for the switch, but this will be called so rarely that's a non-issue.


The point I wanted to illustrate was that, since the OP expressed such a strong dislike for if-tables, there are many ways he can avoid using one while still doing things the "Cocoa Way(tm)". The switch- using code is just one simple example that came to mind.

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
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


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: Over-release *inside* framework when setting NSTextView attributes
  • Next by Date: Re: Ordered Core Data
  • Previous by thread: Re: Getting a reference to an NSMenuItem from another nib?
  • Next by thread: NSOutlineView + NSTreeController + Drag & Drop
  • Index(es):
    • Date
    • Thread