• 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: Weird calculation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird calculation


  • Subject: Re: Weird calculation
  • From: Donald Brown <email@hidden>
  • Date: Thu, 24 Jan 2002 12:51:50 -0600

I think he was talking about popup menus, relying on the order of menu items
(item #1, item #2, etc). Since it's so easy to switch around items in the
Interface Builder, that would crash.

In a similar situation I use a switch, but based on the [menuitem tag].
Even if the menu items are switched around, some removed and some added,
kThatThingYouDo is constant.

Donald

on 1/24/02 11:56 AM, Charles Srstka at email@hidden wrote:

> On Thursday, January 24, 2002, at 08:49 AM, Erik M. Buck wrote:
>
>> This is close to the worst possible way to solve this problem. If you
>> find
>> yourself using switch stsements in Objective-C, you are almost certainly
>> doing something wrong. Your code is very fragile. If you change the
>> order
>> of elements in the pop-up, your code will be wrong. If you add an item
>> to
>> the pop-up your code will be wrong.
>>
>> I suggest that you set a different action for each item in the popup and
>> perform the correct calculation in each action.
>
> You should never use switch statements? What's the correct way to do
> something like this, then:
>
> int answer = NSRunAlertPanel(@"header",@"question",@"button 1",@"button
> 2",@"button 3");

--
Donald Brown
email@hidden
http://www.eamontales.com

We have met the enemy and he is us - Pogo


  • Follow-Ups:
    • Re: Weird calculation
      • From: Ondra Cada <email@hidden>
References: 
 >Re: Weird calculation (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Cocoa DropShell Wanted (Was Re: Implementing Open Document AE in Cocoa)
  • Next by Date: Deutsche Cocoa Entwickler?
  • Previous by thread: Re: Weird calculation
  • Next by thread: Re: Weird calculation
  • Index(es):
    • Date
    • Thread