Re: Protocols on the fly?
Re: Protocols on the fly?
- Subject: Re: Protocols on the fly?
- From: Owen Anderson <email@hidden>
- Date: Mon, 28 Apr 2003 16:20:59 -0400
No, I really do need a Protocol*. Let me explain:
Client application passes me an unknown object. I transfer the object
to another copy of my framework on another computer using DO. Now,
when transferring objects over DO, it is highly recommended that you
provide a Protocol to assign to it once it reaches the client.
However, I want my framework to be as transparent as possible, and
preferable not force my host applications to provide me with a
protocol. Hence my request: give an object of type id, can I
programatically build a Protocol* of the methods it implements? If so,
I could build my own protocol for the object, pass it to the client
separately, and then the client can apply it to the proxy object it
receives.
Hope that makes it clear!
Owen Anderson
On Monday, April 28, 2003, at 08:46 AM, Sherm Pendley wrote:
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.
_______________________________________________
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.