Re: Getting a reference to an NSMenuItem from another nib?
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