• 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: One IBAction, multiple results from multiple methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: One IBAction, multiple results from multiple methods


  • Subject: Re: One IBAction, multiple results from multiple methods
  • From: Klaus Backert <email@hidden>
  • Date: Thu, 26 Feb 2009 10:39:44 +0100


On 26. Feb 2009, at 03:49, I. Savant wrote:

On Feb 25, 2009, at 9:36 PM, Walker Argendeli wrote:

Lets say I have some custom code that does the same thing, with the exception that a few IBOutlets are different for each type. Instead of having multiple methods, is there a way to use 1 IBAction, and take necessary action depending on where it was sent?
<snip>
- (IBAction)seek:(id)sender
{
 int tag = [sender tag];  // or NSInteger tag = [sender tag];
 switch (case)
 {
   case 1001: // seek back
   [self seekBack];
   break;

   case 1002: // seek back FAST
   [self seekBackFast];
   break;

   case 1003: // seek forward
   [self seekForward];
   break;

   case 1004: // seek forward FAST
   [self seekForwardFast];
   break;

   default:
   NSBeep(); // don't know what to do here ...
   break;

 }
}

Don't forget to set the tags in IB for your controls.

... and now we went from a plethora of methods to the same plethora of case statements plus tags.


For the methods the dispatch is made under the hood. The switch statement is kind of re-inventing the objected-oriented wheel in a procedural way.

Klaus

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: One IBAction, multiple results from multiple methods
      • From: "I. Savant" <email@hidden>
    • Re: One IBAction, multiple results from multiple methods
      • From: "I. Savant" <email@hidden>
References: 
 >One IBAction, multiple results from multiple methods (From: Walker Argendeli <email@hidden>)
 >Re: One IBAction, multiple results from multiple methods (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: Radio Buttons not Selecting Properly
  • Next by Date: NSArrayController, only refreshes after mouse moves random key
  • Previous by thread: Re: One IBAction, multiple results from multiple methods
  • Next by thread: Re: One IBAction, multiple results from multiple methods
  • Index(es):
    • Date
    • Thread