Article View: comp.sys.next.programmer
Article #1269Re: Is @selector(foo:) constant?
From: Mike Dixon
Date: Sat, 22 Aug 1992 00:42
Date: Sat, 22 Aug 1992 00:42
32 lines
1260 bytes
1260 bytes
> I tried:
>
> static unsigned int my_array[][3] =
> {
> { 1, @selector(foo:), @selector(bar) },
> ...
> }
>
> The compiler came back and said:
> initializer for static variable is not constant
the trick is that although @selector(foo:) isn't constant, &@selector(foo:)
is. initialize your array with the addresses of the selectors, and
remember to dereference them before you use them. for example, here's
some code from XText:
typedef struct {
SEL *sel;
short arg1;
short arg2;
keyCode key;
} tbl_entry;
const tbl_entry emacs_base[] = {
{&@selector(moveChar:mode:), -1, 0, 0x351}, // ctrl-b move back char
{&@selector(moveChar:mode:), -1, 1, 0x401}, // ctrl-h delete back char
... etc.
--
.mike.
Technical Details
Message-ID:
<mdixon.714444125@thelonius>Path:
arc1-ca.pugleaf.net!sparky!uunet!decwrl!parc!mdixonReferences:
<1992Aug21.180854.24973@wuecl.wustl.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!parc!mdixon From: mdixon@parc.xerox.com (Mike Dixon) Subject: Re: Is @selector(foo:) constant? Message-ID: <mdixon.714444125@thelonius> Keywords: @selector, Objective-C, constant Sender: news@parc.xerox.com Organization: Xerox PARC References: <1992Aug21.180854.24973@wuecl.wustl.edu> Date: 22 Aug 92 00:42:05 GMT Lines: 32