Re: Protocols on the fly?
Re: Protocols on the fly?
- Subject: Re: Protocols on the fly?
- From: Sherm Pendley <email@hidden>
- Date: Mon, 28 Apr 2003 08:46:20 -0400
On Monday, April 28, 2003, at 07:19 AM, Owen Anderson wrote:
I'm receiving an object of type id that I know nothing about. I want
to create a protocol * of methods.
If what you want to do is get a list of the methods implemented by an
object, information about each method (return and arg types), and type
information about any instance variables it has, you don't need a
protocol to do any of that.
For a detailed look at the Objective-C runtime, see "The Objective-C
Programming Language," available from Apple in PDF form at
<
http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/ObjC.pdf>.
(Note that, despite having the same file name, this is *not* the same
PDF that ships with the developer tools.)
It's worth noting that, since you're using DO, the class definition
pointed to by your object's isa member is probably that of a proxy
object that's forwarding messages to a distant object, not that of the
distant object itself. So, the class definition you get won't be what
you expect.
In this case, it's probably simpler to map out a formal protocol that
you and the other programmers will use, include that header file in the
code on both ends, and send incoming objects a conformsToProtocol:
message to double-check. Or, failing that, simply use
respondsToSelector: messages to find out if the remote object implements
the methods you want to use.
sherm--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.