Re: SELs in arrays
Re: SELs in arrays
- Subject: Re: SELs in arrays
- From: Peter Ammon <email@hidden>
- Date: Wed, 26 Sep 2001 16:52:41 -0400
On Tuesday, September 25, 2001, at 03:04 PM, Ondra Cada wrote:
John,
John C. Randolph (JCR) wrote at Tue, 25 Sep 2001 11:45:20 -0700:
JCR> >I guess it would be cleaner using NSValue, but I'm just used to
the
JCR> >integers ;)))
JCR>
JCR> This won't work, since on Mac OS X and NEXTSTEP, selectors aren't
JCR> integers, but uniqued C strings:
This *will* work, since in any ObjC implementation selectors are
convertible
to int. In NeXT (and therefore Apple) ObjC they are just pointers --
which
is a type convertible to int all right.
A pointer can be converted to an integral type that's big enough to hold
it, and the conversion is implementation defined. C doesn't guarantee
that any integral type is big enough to hold a pointer, so it's
perfectly possible for there to be an ObjC implementation where you
cannot convert a SEL to an int.
However, it's guaranteed to work with gcc/PowerPC, since the
implementation defines it to be that way.
-Peter