Re: Problem using data in a distributed object
Re: Problem using data in a distributed object
- Subject: Re: Problem using data in a distributed object
- From: Ken Thomases <email@hidden>
- Date: Mon, 30 May 2011 12:26:54 -0500
On May 30, 2011, at 12:08 PM, email@hidden wrote:
> Thanks Ken
You're welcome.
> How do I specify "by copy" when sending?
>
> For example, say object A sends data to B like so:
>
> [objectB performSelector: @selector(handleRequest:) withObject: vendedObject];
I'm not sure what you're getting at here. The mention of vendedObject suggests that you're thinking of bycopy in the wrong way, that you're thinking it's a way of treating an object after you've already received it via D.O. Rather, bycopy describes what you receive via D.O.
Your earlier case involved a string, and strings are almost always value objects suitable for copying, rather than sharing. That is, it doesn't make much sense to share an immutable string between the client and server, and it would be hideous to share a mutable string where you wanted changes done by either to be visible to both. Therefore, you'd use something like the following to obtain a string:
- (bycopy NSString*) getSomeString;
In the client:
NSString* aString = [serverRootProxy getSomeString];
After that, aString is independent from the server.
If that's not what you were asking, then I'm not sure if you can specify bycopy with a -performSelect:... method. I don't know how D.O. handles -performSelector:withObject:. I don't know if it encodes that method or if it encodes the method to be performed (here -handleRequest:).
Why are you doing it this way? Why not:
[objectB handleRequest:vendedObject]
? In that case, you'd declare -handleRequest: with the bycopy qualifier on its argument. Although, again, having just written the above code snippet, it's very peculiar that you already have a vended object and _now_ you're worrying about how to pass it by-copy to -handleRequest:. That's the wrong way to think about it.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden