Re: One IBAction, multiple results from multiple methods
Re: One IBAction, multiple results from multiple methods
- Subject: Re: One IBAction, multiple results from multiple methods
- From: Dave DeLong <email@hidden>
- Date: Thu, 26 Feb 2009 09:20:42 -0700
Here's one for you:
I created a small app for the purpose of testing how to post CGEvents
and ended up building a keyboard in a window out of a whole bunch of
NSButtons. I didn't want to wire up each button to a separate
IBAction, because that would've been about 100 IBActions all doing the
same thing (the only difference being which keycode to dispatch). So
I created one IBAction, then hardcoded the keycode as the tag of each
button.
It would've been REALLY nice to put something like the following into
my .h file and have IB autodiscover it:
#define IBTag KEYCODE_A 0
#define IBTag KEYCODE_Z 6
...etc
And then have the tag field autocomplete those in IB. I think anyone
who would later look at my code would understand a heck of a lot
better what's going on. Yes, it's theoretically more work (to do both
the #defines and the tag hardcoding), but when you look at a button in
IB and see a tag of "42", I don't know anyone who thinks "aha, that's
a backslash". But if it were "KEYCODE_BACKSLASH_PIPE", that would
make a whole lot more sense. =)
Dave
On Feb 26, 2009, at 9:11 AM, I. Savant wrote:
On Thu, Feb 26, 2009 at 10:53 AM, Michael Ash
<email@hidden> wrote:
It's true that there are scenarios where dispatching off the tags are
helpful, but I don't think that this is one of them.
You're absolutely right, it's a stretch to use this example because
it's not complicated enough to highlight the point I'm making.
Laziness is my only excuse for not providing a more complex example.
:-)
_______________________________________________
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