How is @selector resolved at compile time ?
How is @selector resolved at compile time ?
- Subject: How is @selector resolved at compile time ?
- From: "Erik M. Buck" <email@hidden>
- Date: Wed, 25 Jul 2001 21:53:05 -0500
Suppose I have several different frameworks that all use a particular selector
via @selector(someSelector). How do the compiler and runtime make sure that
@selector(someSelector) always results in the same value (pointer) in separate
compilation units in separate frameworks ? Are selector values that result
from @selector somehow fixed-up when a framework is loaded ? They would have
to be to make sure that all frameworks in a running application have the same
value for the same selector. How could that fix-up be implemented ? Does
every occurrence of @selector result in a lookup at run-time each time it is
encountered ?
if I write the following:
int i;
for(i = 0; i < 10000; i++) {
[NSObject performSelector:@selector(description)];
}
Is the value of @selector(description) looked up 10000 times or once or not at
all because the compiler took care of it ?