Re: Is selector in protocol?
Re: Is selector in protocol?
- Subject: Re: Is selector in protocol?
- From: "John C. Randolph" <email@hidden>
- Date: Wed, 24 Oct 2001 17:04:47 -0700
On Wednesday, October 24, 2001, at 03:20 PM, Erik M. Buck wrote:
----- Original Message -----
From: "John C. Randolph" <email@hidden>
How about
if([@protocol(someProtocol)
descriptionForInstanceMethod:theSelector])
I don't think this is legal. @protocol is a compiler directive to
begin
a protocol declaration, like @interface or @implementation. It's not
like @selector or @encode.
That line should be:
if([someProtocol descriptionForInstanceMethod:theSelector])
-jcr
@protocol() works exactly like @selector() ! The Apple Objective-C
run-time
creates protocol objects just like it creates class objects. @protocol
is a
way to get a pointer to the run-time created protocol object that is an
instance of class Protocol.
See page 101 of "Object Oriented Programming and the Objective-C
Language"
Protocol *counter = @protocol(ReferenceCounting);
Hmm...
Then it's the only obj-c keyword I can think of that has both a
function-like form and an @keyword..@end form.
I've written
@protocol myProtocol
-someMethod;
@end
any number of times, but I've never had occasion to use the @protocol()
form.
-jcr
"I fear all we have done is to awaken a sleeping giant and fill him with
a terrible resolve." -Admiral Isoroku Yamamoto, Dec 7, 1941.